pyufunc.send_email#
- pyufunc.send_email(send_from, send_to, subject, message, smtp_user, smtp_password, file_path=[], cc=[], bcc=[], **kwargs)#
Send email with attachments.
- Parameters:
send_from (str) – email address of the sender
send_to (str | list) – email address of the receiver, can be a list of email addresses
subject (str) – email subject
message (str) – the email body
smtp_user (str) – user name of the smtp server, normally the same as the email address
smtp_password (str) – password of the smtp server, if you use gmail, you need to generate an app password
file_path (str | list, optional) – _description_. Defaults to [].
**kwargs – Optional email settings, including
message_typeandverbose.
- Raises:
ValueError – Invalid email address:
ValueError – send_to should be a list or a string of email addresses
ValueError – Invalid email address:
ValueError – file_path should be a list of file paths
ValueError – Invalid file:
ValueError – Unknown email provider:
Note
- User can add message_type = “html” in the kwargs.
If message_type is “html”, the message will be sent as html format. eg. message_type = “html”, message = “<h1>hello world</h1>”
- User can add verbose = True in the kwargs.
If verbose is True, the function will print the email sending status.
- If you are using gmail, you need to generate an app password
for the smtp_password: https://support.google.com/accounts/answer/185833?hl=en
- Returns:
True if the email is sent successfully, False otherwise
- Return type:
Examples
>>> from pyufunc import send_email >>> send_email(send_from="", send_to="", subject="", message="", >>> smtp_user="", smtp_password="", file_path="", cc="", bcc="")