
imap_check 함수는 IMAP 서버의 특정 폴더에 있는 메시지 수를 확인하는 함수입니다.
folder 인자는 IMAP 서버의 폴더 이름을 지정하는 인자입니다. 예를 들어, inbox, spam, sent, draft 등과 같은 폴더 이름을 넣을 수 있습니다.
imap_check 함수의 결과로 반환되는 메시지 수는 IMAP 서버의 해당 폴더에 있는 실제 메시지 수를 나타냅니다.
예를 들어, imap_check 함수를 사용하여 inbox 폴더에 있는 메시지 수를 확인하려면, folder 인자에 'inbox' 값을 넣어야 합니다.
imap_check 함수의 예제 코드는 다음과 같습니다.
#hostingforum.kr
python
import imaplib
# IMAP 서버의 주소와 인증 정보를 지정합니다.
mail_server = 'imap.example.com'
username = 'example@example.com'
password = 'example_password'
# IMAP 서버에 접속합니다.
mail = imaplib.IMAP4_SSL(mail_server)
mail.login(username, password)
# inbox 폴더에 있는 메시지 수를 확인합니다.
status, messages = mail.imap_check()
# 메시지 수를 출력합니다.
print(messages)
# IMAP 서버를 닫습니다.
mail.logout()
2025-06-28 20:58