IMAP 확장 활성화
Contents
[
Hide
]
IMAP 확장 지원
Aspose.Email API는 다양한 IMAP 프로토콜 확장을 지원합니다. 이러한 확장은 클라이언트 애플리케이션 식별 및 상세한 메일함 메타데이터 검색과 같은 고급 작업을 가능하게 합니다. 모든 이메일 서버가 이러한 기능을 지원하는 것은 아니지만, Gmail과 같은 많은 인기 서비스는 지원합니다.
이 문서는 다음 IMAP 확장들을 사용하는 방법을 보여줍니다. ImapClient Aspose.Email의 클래스:
-
IMAP ID 명령
-
IMAP LIST-EXTENDED 명령
IMAP ID 명령 사용
이 명령은 서버가 IMAP ID 확장을 지원하는지 여부를 알려주고, 서버로부터 구조화된 식별 세부 정보를 반환합니다. 이는 로깅, 진단 및 서버 동작 맞춤화에 유용합니다.
다음 코드 샘플은 Aspose.Email 라이브러리를 사용하여 IMAP 서버와 상호 작용하고, 특히 ID 명령을 사용해 서버 식별 정보를 가져오는 방법을 보여줍니다:
import aspose.email as ae
with ae.clients.imap.ImapClient("imap.gmail.com", 993, "username", "password") as client:
# Set security options
client.security_options = ae.clients.SecurityOptions.AUTO
# Check if ID command is supported
print(client.id_supported)
# Send identification info to the server
server_identification_info1 = client.introduce_client()
server_identification_info2 = client.introduce_client(ae.clients.imap.ImapIdentificationInfo.default_value)
# Display server response
print(server_identification_info1)
print(server_identification_info2)
print(server_identification_info1.name)
print(server_identification_info1.vendor)
print(server_identification_info1.support_url)
print(server_identification_info1.version)
IMAP LIST-EXTENDED 명령 사용
IMAP LIST-EXTENDED 명령(RFC 5258에 정의됨)은 클라이언트가 폴더 계층 구조 및 메타데이터(예: 폴더에 하위 폴더가 있는지 여부)를 상세히 가져올 수 있게 합니다. 이는 복잡한 메일함 구조를 관리하는 클라이언트에 특히 유용합니다.
다음 코드 샘플은 확장 LIST 명령을 사용하여 Gmail에서 폴더 목록을 표시하고 어떤 폴더에 하위 폴더가 포함되어 있는지 확인하는 방법을 보여줍니다:
import aspose.email as ae
with ae.clients.imap.ImapClient("imap.gmail.com", 993, "username", "password") as client:
folder_info_col = client.list_folders("*")
print("Extended List Supported:", client.extended_list_supported)
for folder_info in folder_info_col:
folder_name = folder_info.name
if folder_name == "[Gmail]/All Mail":
print("Has Children:", folder_info.has_children)
elif folder_name == "[Gmail]/Bin":
print("Bin has children?", folder_info.has_children)
elif folder_name == "[Gmail]/Drafts":
print("Drafts has children?", folder_info.has_children)
elif folder_name == "[Gmail]/Important":
print("Important has Children?", folder_info.has_children)
elif folder_name == "[Gmail]/Sent Mail":
print("Sent Mail has Children?", folder_info.has_children)
elif folder_name == "[Gmail]/Spam":
print("Spam has Children?", folder_info.has_children)
elif folder_name == "[Gmail]/Starred":
print("Starred has Children?", folder_info.has_children)