
imap_undelete 함수는 IMAP 서버에서 삭제된 메일을 복구하는 데 사용됩니다. 기본 사용법은 다음과 같습니다.
#hostingforum.kr
python
import imaplib
mail = imaplib.IMAP4_SSL('imap 서버 주소')
mail.login('이메일 주소', '비밀번호')
mail.select('복구할 폴더 이름')
status, messages = mail.search(None, 'ALL')
uid_list = messages[0].split()
mail.select('복구할 폴더 이름')
mail.copy(uid_list, '복구할 폴더 이름')
mail.store(uid_list, '+FLAGS', '\Seen')
mail.expunge()
mail.close()
mail.logout()
imap_undelete 함수의 옵션 중 'uid' 옵션을 사용하는 경우, 메일 아이디 대신 우편함 아이디를 사용할 필요는 없습니다. 'uid' 옵션은 메일의 고유 아이디를 사용하여 삭제된 메일을 복구할 때 사용됩니다.
imap_undelete 함수를 사용하여 복구한 메일은 imap_folder_copy 함수를 사용하여 다른 폴더로 이동할 수 있습니다. imap_folder_copy 함수는 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
python
mail.copy(uid_list, '다른 폴더 이름')
이 함수를 사용하면 복구한 메일을 다른 폴더로 이동할 수 있습니다.
2025-05-03 07:26