Fix replacement image and change to header

This commit is contained in:
2019-10-29 16:47:52 +01:00
parent 25af4b422a
commit bacc05cb41
2 changed files with 8 additions and 6 deletions

View File

@@ -100,9 +100,9 @@ The following configuration options are optional in each quarantine section:
* **notification_email_envelope_from** * **notification_email_envelope_from**
Notification e-mail envelope from-address. Notification e-mail envelope from-address.
* **notification_email_from** * **notification_email_from**
Value of the notification e-mail from header. Every e-mail template variable described above is usable. Value of the notification e-mail from header. Optionally, you may use the EMAIL_FROM template variable described above.
* **notification_email_subject** * **notification_email_subject**
Notification e-mail subject. All e-mail template variable described above is usable. Notification e-mail subject. Optionally, you may use the EMAIL_SUBJECT template variable described above.
* **notification_email_template** * **notification_email_template**
Path to the notification e-mail template. It is hold in memory during runtime. Path to the notification e-mail template. It is hold in memory during runtime.
* **notification_email_embedded_imgs** * **notification_email_embedded_imgs**

View File

@@ -188,7 +188,7 @@ class EMailNotification(BaseNotification):
# read email replacement image if specified # read email replacement image if specified
replacement_img = self.config["notification_email_replacement_img"].strip() replacement_img = self.config["notification_email_replacement_img"].strip()
if not strip_images and replacement_img: if not self.strip_images and replacement_img:
try: try:
self.replacement_img = MIMEImage( self.replacement_img = MIMEImage(
open(replacement_img, "rb").read()) open(replacement_img, "rb").read())
@@ -391,9 +391,11 @@ class EMailNotification(BaseNotification):
htmltext = self.template.format_map(variables) htmltext = self.template.format_map(variables)
msg = MIMEMultipart('related') msg = MIMEMultipart('related')
msg["Subject"] = self.subject.format_map(variables) msg["From"] = self.from_header.format_map(
msg["From"] = "{}".format(self.from_header.format_map(variables)) defaultdict(str, EMAIL_FROM=headers["from"]))
msg["To"] = "<{}>".format(recipient) msg["To"] = headers["to"]
msg["Subject"] = self.subject.format_map(
defaultdict(str, EMAIL_SUBJECT=headers["subject"]))
msg["Date"] = email.utils.formatdate() msg["Date"] = email.utils.formatdate()
msg.attach(MIMEText(htmltext, "html", 'UTF-8')) msg.attach(MIMEText(htmltext, "html", 'UTF-8'))