Skip to content

Commit

Permalink
updated Send Email in Imap
Browse files Browse the repository at this point in the history
Bcc now works again
  • Loading branch information
Mephisto2409 committed Nov 29, 2024
1 parent 06ca25c commit 627dd94
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions EMailService.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ def send_email(self, email:Email) -> bool:
msg['From'] = from_email
msg['To'] = to
msg['Cc'] = cc
#not working
#msg['Bcc'] = bcc
msg['Bcc'] = ",".join(bcc)
msg.set_content(email.body)

#attachment
Expand Down Expand Up @@ -302,9 +301,9 @@ def imap_test():
imap = ImapProtocol()
test = Email(

subject="Hellololololo",
subject="TestBCC",
body="Test time!!",
recipients=[EmailReception(contact=(Contact(email_address ="praxisprojekt-remail@uni-due.de")), kind=RecipientKind.to),EmailReception(contact=(Contact(email_address ="toadbella@gmail.com")), kind=RecipientKind.to)],
recipients=[EmailReception(contact=(Contact(email_address ="praxisprojekt-remail@uni-due.de")), kind=RecipientKind.to),EmailReception(contact=(Contact(email_address ="toadbella@gmail.com")), kind=RecipientKind.bcc),EmailReception(contact=(Contact(email_address ="Karolinebock2409@web.de")), kind=RecipientKind.bcc)],
#attachments=[Attachment(filename=r"C:\Users\toadb\Documents\ReinventingEmail\test.txt")])
)
print("IMAP Logged_in: ",imap.logged_in)
Expand All @@ -325,7 +324,7 @@ def exchange_test():


#exchange
import keyring
#import keyring

test = Email(

Check failure on line 329 in EMailService.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F841)

EMailService.py:329:5: F841 Local variable `test` is assigned to but never used

Expand All @@ -336,7 +335,7 @@ def exchange_test():


print("Exchange Logged_in: ",exchange.logged_in)
exchange.login("praxisprojekt-remail@uni-due.de",keyring.get_password("remail/exchange","praxisprojekt-remail@uni-due.de"))
#exchange.login("praxisprojekt-remail@uni-due.de",keyring.get_password("remail/exchange","praxisprojekt-remail@uni-due.de"))
print("Exchange Logged_in: ",exchange.logged_in)
emails = exchange.get_emails(datetime(2024,11,29,9,28,tzinfo=UTC))
print(emails)
Expand Down Expand Up @@ -370,8 +369,8 @@ def get_contact(email : str) -> Contact:

if __name__ == "__main__":
print("Starte Tests")
#imap_test()
exchange_test()
imap_test()
#exchange_test()
print("Tests beendet")


Expand Down

0 comments on commit 627dd94

Please sign in to comment.