Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from imap_tools import MailBox
- import re
- def get_msg(email_name: str, email_password: str) -> str:
- email_url = 'imap.poczta.onet.pl'
- email_folder = 'INBOX'
- regex= "\d{6}" # 6 is number of digits of code
- with MailBox(email_url).login(email_name, email_password, email_folder) as mailbox:
- for msg in mailbox.fetch(limit=1, reverse=True):
- code = re.findall(regex, msg.subject)[0]
- return code
- def main():
- email_login = '<some_login>@onet.eu'
- email_password = '<some_password>'
- print(get_msg(email_name, email_password))
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment