gws.plugin.email_helper¶
Email helper.
The email helper sends email messages over SMTP. A Message has a
subject, recipients, an optional sender and Bcc addresses, a plain text part
and an optional HTML part. Both parts are encoded as quoted-printable. If the
message has no sender, the configured mailFrom is used.
The SMTP connection mode is ssl (SMTP over SSL, default port 465),
tls (STARTTLS, default port 587) or plain (no encryption, default
port 25). If login is set, the helper logs in before sending.
The helper is used, for example, by the email multi-factor adapter
(gws.plugin.auth_mfa.email) and the account plugin. It must be configured
with an SMTP server.
Example:
helpers+ {
type "email"
mailFrom "gws@example.com"
smtp {
host "smtp.example.com"
mode "tls"
login "gws"
password "secret"
}
}
Usage in Python:
helper = cast(gws.plugin.email_helper.Object, root.app.helper('email'))
helper.send_mail(gws.plugin.email_helper.Message(
subject='Hello',
mailTo='user_1@example.com',
text='Hello, world.',
))
Source code: gws.plugin.email_helper
Package Contents¶
- class gws.plugin.email_helper.Config(*args, **kwargs)¶
Bases:
gws.ConfigSending of emails via SMTP.
- smtp: SmtpConfig¶
SMTP server configuration.
- class gws.plugin.email_helper.Object¶
Bases:
gws.NodeEmail helper.
- smtp: _SmtpServer¶
SMTP server settings.
- configure()¶
Configuration hook.
Called when the node is initialized. Raising an exception here aborts the creation of the node.
- class gws.plugin.email_helper.SmtpConfig(*args, **kwargs)¶
Bases:
gws.ConfigSMTP server configuration.
- timeout: gws.Duration = '30'¶
Connection timeout.