tempmail python
2.3.3 - Python 3.7+ support
tempmail-python은 1secmail 서비스를 사용하여 임시 이메일 주소를 생성하고 관리하기 위한 Python 라이브러리입니다. 이메일 주소 생성, 새 메시지 확인, 메시지 내용 검색 기능을 제공합니다.
pip를 사용하여 tempmail-python을 설치할 수 있습니다.
pip install tempmail-python
또는 소스에서 설치할 수도 있습니다.
pip install git+https://github.com/cubicbyte/tempmail-python.git
메시지 수신(예: 활성화 코드)
from tempmail import EMail
email = EMail ()
print ( email . address ) # [email protected]
# ... request some email ...
msg = email . wait_for_message ()
print ( msg . body ) # Hello World!n
받은편지함의 모든 메시지 가져오기
from tempmail import EMail
email = EMail ( '[email protected]' )
inbox = email . get_inbox ()
for msg_info in inbox :
print ( msg_info . subject , msg_info . message . body )
첨부파일 다운로드
from tempmail import EMail
email = EMail ( username = 'example' , domain = '1secmail.com' )
msg = email . wait_for_message ()
if msg . attachments :
attachment = msg . attachments [ 0 ]
data = attachment . download ()
# Print
print ( data ) # b'Hello World!n'
print ( data . decode ( 'utf-8' )) # Hello World!n
# Save to file
with open ( attachment . filename , 'wb' ) as f :
f . write ( data )
레딧 활성화 코드 받기
from tempmail import EMail
def reddit_filter ( msg ):
return ( msg . from_addr == '[email protected]' and
msg . subject == 'Verify your Reddit email address' )
email = EMail ( address = '[email protected]' )
msg = email . wait_for_message ( filter = reddit_filter )
# get_activation_code(html=msg.html_body)
기타 기능:
from tempmail . providers import OneSecMail
email = OneSecMail ()
# request_email(email=email.address)
# Speed up inbox refresh rate
OneSecMail . inbox_update_interval = 0.1 # every 100ms
# Accept only emails with a specific subject, raise error after 60 seconds
msg = email . wait_for_message ( timeout = 60 , filter = lambda m : m . subject == 'Hello World!' )
print ( msg . body )
tempmail-python은 MIT 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 LICENSE 파일을 참조하세요.