Skip to content

Commit

Permalink
Merge pull request #213 from multiflexi/mailer-logging
Browse files Browse the repository at this point in the history
Add logging messages to mailer, improved SMTP communication
  • Loading branch information
Progress1 authored Mar 7, 2024
2 parents dc08d4a + 74a6177 commit 629a14e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/publishers/publishers/email_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def publish(self, publisher_input):
envelope.subject(subject)
envelope.from_(sender)
envelope.to(recipients)
envelope.smtp(smtp)

if sign == "auto":
envelope.signature(key=sign)
Expand All @@ -113,8 +112,15 @@ def publish(self, publisher_input):
log_manager.log_info(f"Encrypting email with file {encrypt}")
envelope.encryption(key=open(encrypt))

envelope.smtp(smtp)
try:
envelope.send()
sent = envelope.send()
success = bool(sent)
if success:
log_manager.log_info("Email sent successfully")
Envelope.smtp_quit()
else:
log_manager.log_critical("Email sending failed")

except Exception as error:
BasePublisher.print_exception(self, error)

0 comments on commit 629a14e

Please sign in to comment.