Add HTML support for Google Mail messages (#87201)

This commit is contained in:
Robert Hillis 2023-03-28 08:34:57 -04:00 committed by GitHub
parent cc404cfe77
commit 8e7013b079
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
import base64 import base64
from email.message import EmailMessage from email.mime.text import MIMEText
from typing import Any from typing import Any
from googleapiclient.http import HttpRequest from googleapiclient.http import HttpRequest
@ -43,8 +43,7 @@ class GMailNotificationService(BaseNotificationService):
data: dict[str, Any] = kwargs.get(ATTR_DATA) or {} data: dict[str, Any] = kwargs.get(ATTR_DATA) or {}
title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT) title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)
email = EmailMessage() email = MIMEText(message, "html")
email.set_content(message)
if to_addrs := kwargs.get(ATTR_TARGET): if to_addrs := kwargs.get(ATTR_TARGET):
email["To"] = ", ".join(to_addrs) email["To"] = ", ".join(to_addrs)
email["From"] = data.get(ATTR_FROM, ATTR_ME) email["From"] = data.get(ATTR_FROM, ATTR_ME)