Gmail
Send emails via Gmail
This is a private use case of the SMTP provider, with Gmail’s server as default:
>>> from notifiers import get_notifier
>>> gmail = get_notifier('gmail')
>>> gmail.defaults
{'subject': "New email from 'notifiers'!", 'from': 'notifiers@<hostname>', 'host': 'smtp.gmail.com', 'port': 587, 'tls': True, 'ssl': False, 'html': False, 'login': True}
>>> gmail.notify(to='email@addrees.foo', message='hi!', username='me@gmail.com', password='APP-PASSWORD')
Arguments:
Argument |
Type |
Required |
Description |
|---|---|---|---|
|
str |
yes |
the content of the email message |
|
str |
the subject of the email message. Default: “New email from ‘notifiers’!” |
|
|
str or list of str |
yes |
one or more email addresses to use |
|
str or list of str |
one or more email addresses to use |
|
|
str or list of str |
one or more email addresses to use |
|
|
str |
the FROM address to use in the email. Default: ‘notifiers@<hostname>’ |
|
|
str or list of str |
one or more attachments to use in the email |
|
|
str |
the host of the SMTP server. Default: ‘smtp.gmail.com’ |
|
|
int |
the port number to use. Default: 587. ≥ 0, ≤ 65535 |
|
|
str |
username if relevant |
|
|
str |
password if relevant |
|
|
bool |
should TLS be used. Default: True |
|
|
bool |
should SSL be used. Default: False |
|
|
bool |
should the email be parse as an HTML file. Default: False |
|
|
bool |
Trigger login to server. Default: True |