The SMTP Extension includes the SMTPMailHandler
, and provides the ability for applications to send email via standard SMTP.
Documentation References:
​Mail Messaging​
API References:
​Cement SMTP Extension​
​Python SMTP Library​
No external depencies
This extension supports the following configuration settings under a [mail.dummy]
configuration section:
Setting | Description |
to | Default recipient address (list, or comma separated depending on the config handler in use). |
from_addr | Default sender address |
cc | Default carbon-copy addresses (list, or comma separated depending on the config handler in use) |
bcc | Default blind-carbon-copy addresses (list, or comma separated depending on the config handler in use) |
subject | Default subject line |
subject_prefix | Additional string to prepend to the subject line of all messages |
host | The SMTP host server address. Default: |
port | The SMTP host server port. Default: |
timeout | The timeout in seconds before terminating a connection. Default: 30 |
ssl | Whether to initiate SSL or not. Default: |
tls | Whether to use TLS or not (requires SSL). Default: |
auth | Whether or not to initiate SMTP authentication. Default: |
username | SMTP authentication username. Default: |
password | SMTP authentication password. Default: |
myapp.pyfrom cement import App​class MyApp(App):class Meta:label = 'myapp'mail_handler = 'smtp'​with MyApp() as app:app.run()app.mail.send('This is my fake message',subject='This is my subject',to=['john@example.com', 'rita@example.com'],from_addr='me@example.com',)
~/.myapp.conf[myapp]​# set the mail handler to usemail_handler = smtp​​[mail.smtp]​# default to addresses (comma separated list)to = me@example.com​# default from addressfrom = someone_else@example.com​# default cc addresses (comma separated list)cc = jane@example.com, rita@example.com​# default bcc addresses (comma separated list)bcc = blackhole@example.com, someone_else@example.com​# default subjectsubject = This is The Default Subject​# additional prefix to prepend to the subjectsubject_prefix = MY PREFIX >​# smtp host serverhost = localhost​# smtp host portport = 465​# timeout in secondstimeout = 30​# whether or not to establish an ssl connectionssl = true​# whether or not to use start tlstls = true​# whether or not to initiate smtp authauth = true​# smtp auth usernameusername = john.doe​# smtp auth passwordpassword = oober_secure_password