mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Add HTML support for Google Mail messages (#87201)
This commit is contained in:
parent
cc404cfe77
commit
8e7013b079
@ -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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user