Mercurial > libervia-backend
diff libervia/backend/tools/common/email.py @ 4298:060d695ae98e
plugin XEP-0106, tools (common/email): type hints.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 06 Sep 2024 17:44:08 +0200 |
parents | 0d7bb4df2343 |
children |
line wrap: on
line diff
--- a/libervia/backend/tools/common/email.py Fri Sep 06 17:42:07 2024 +0200 +++ b/libervia/backend/tools/common/email.py Fri Sep 06 17:44:08 2024 +0200 @@ -20,7 +20,9 @@ """email sending facilities""" +from configparser import ConfigParser from email.mime.text import MIMEText +from twisted.internet import defer from twisted.mail import smtp from libervia.backend.core.constants import Const as C from libervia.backend.tools import config as tools_config @@ -29,16 +31,22 @@ log = getLogger(__name__) -def send_email(config, to_emails, subject="", body="", from_email=None): - """Send an email using SàT configuration +def send_email( + config: ConfigParser, + to_emails: list[str] | str, + subject: str = "", + body: str = "", + from_email: str | None = None, +) -> defer.Deferred: + """Send an email using Libervia configuration - @param config (ConfigParser): the configuration instance - @param to_emails(list[unicode], unicode): list of recipients + @param config: the configuration instance + @param to_emails: list of recipients if unicode, it will be split to get emails - @param subject(unicode): subject of the message - @param body(unicode): body of the message - @param from_email(unicode): address of the sender - @return (D): same as smtp.sendmail + @param subject: subject of the message + @param body: body of the message + @param from_email: address of the sender + @return:Same as smtp.sendmail. """ if isinstance(to_emails, str): to_emails = to_emails.split()