Skip to content

Commit

Permalink
fix: properly format SMTP from address/name (#1782)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-genson authored Oct 27, 2022
1 parent 1e3c0b0 commit 0dfb3a8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions mealie/services/email/email_senders.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ class SMTPResponse:
class Message:
subject: str
html: str
mail_from: tuple[str, str]
mail_from_name: str
mail_from_address: str

def send(self, to: str, smtp: EmailOptions) -> SMTPResponse:
msg = message.EmailMessage()
msg["Subject"] = self.subject
msg["From"] = self.mail_from
msg["From"] = f"{self.mail_from_name} <{self.mail_from_address}>"
msg["To"] = to
msg.add_alternative(self.html, subtype="html")

Expand Down Expand Up @@ -75,7 +76,8 @@ def send(self, email_to: str, subject: str, html: str) -> bool:
message = Message(
subject=subject,
html=html,
mail_from=(self.settings.SMTP_FROM_NAME, self.settings.SMTP_FROM_EMAIL),
mail_from_name=self.settings.SMTP_FROM_NAME,
mail_from_address=self.settings.SMTP_FROM_EMAIL,
)

if self.settings.SMTP_HOST is None or self.settings.SMTP_PORT is None:
Expand Down

0 comments on commit 0dfb3a8

Please sign in to comment.