Sending Email Messages¶
Please note that there are other handlers that implement the
interface. The documentation below only references usage based on the
interface and not the full capabilities of the implementation.
The following mail handlers are included and maintained with Cement:
Please reference the IMail interface documentation for writing your own mail handler.
from cement.core.foundation import CementApp class MyApp(CementApp): class Meta: label = 'myapp' with MyApp() as app: app.run() # send an email message app.mail.send('This is my message', subject='This is my subject', to=['firstname.lastname@example.org'], email@example.com', cc=['firstname.lastname@example.org', 'email@example.com'], bcc=['firstname.lastname@example.org'] )
Note that the default mail handler simply prints messages to the screen, and does not actually send anything. You can override this pretty easily without changing any code by using the built-in SMTPMailHandler. Simply modify the application configuration to something like:
[myapp] mail_handler = smtp [mail.smtp] ssl = 1 tls = 1 auth = 1 username = john.doe password = oober_secure_password