Mail agent added
This commit is contained in:
28
tests/email_client/test_email_client.py
Normal file
28
tests/email_client/test_email_client.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
import sys
|
||||
sys.path.append('./src')
|
||||
|
||||
load_dotenv()
|
||||
|
||||
from mail_order_bot.email_client import EmailClient
|
||||
|
||||
if __name__ == "__main__":
|
||||
email_client = EmailClient(
|
||||
imap_host=os.getenv('IMAP_HOST'),
|
||||
smtp_host=os.getenv('SMTP_HOST'),
|
||||
email=os.getenv('EMAIL_USER'),
|
||||
password=os.getenv('EMAIL_PASSWORD'),
|
||||
imap_port=os.getenv('IMAP_PORT'),
|
||||
smtp_port=os.getenv('SMTP_PORT')
|
||||
)
|
||||
emails = email_client.get_emails(folder='spareparts', only_unseen=True, mark_as_read=True)
|
||||
for email in emails:
|
||||
print(email.subj)
|
||||
print(email.from_addr)
|
||||
print(email.dt)
|
||||
print(email.body)
|
||||
print(email.first_sender)
|
||||
print('--------------------------------')
|
||||
|
||||
email_client.close()
|
||||
Reference in New Issue
Block a user