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

message

str

yes

the content of the email message

subject

str

the subject of the email message. Default: “New email from ‘notifiers’!”

to

str or list of str

yes

one or more email addresses to use

cc

str or list of str

one or more email addresses to use

bcc

str or list of str

one or more email addresses to use

from (also from_)

str

the FROM address to use in the email. Default: ‘notifiers@<hostname>’

attachments

str or list of str

one or more attachments to use in the email

host

str

the host of the SMTP server. Default: ‘smtp.gmail.com’

port

int

the port number to use. Default: 587. ≥ 0, ≤ 65535

username

str

username if relevant

password

str

password if relevant

tls

bool

should TLS be used. Default: True

ssl

bool

should SSL be used. Default: False

html

bool

should the email be parse as an HTML file. Default: False

login

bool

Trigger login to server. Default: True