utilities - send_email
The send_email
module provides classes for sending emails from Jython.
- The code automatically sets the charset of the mail to utf-8 when non-ascii characters are detected.
Classes
_Email
Base class that all other classes inherit from.
Methods
Function | Parameters | Return Value | Description |
---|---|---|---|
_Email.send(self) | Sends the email using the SMTP server configured in smtp_server_adress |
SimpleEmail
Methods
Function | Parameters | Return Value | Description |
---|---|---|---|
SimpleEmail.__init__(self, subject, from_address, recipients, message_text) | subject: subject of the email from_address: address the email was sent from recipients: list of email addresses of all recipients message_text: plain text message | SimpleEmail instance | Initializes a new SimpleEmail object |
HtmlEmail
Methods
Function | Parameters | Return Value | Description |
---|---|---|---|
HtmlEmail.__init__(self, subject, from_address, recipients, html_content, plain_text_content='') | subject: subject of the email from_address: address the email should appear to be sent from recipients: list of email addresses of all recipients html_content: HTML content of the message plain_text_content: plain text fallback to send with the email | HtmlEmail instance | Initializes a new HtmlEmail object |
Examples
Sending a plain text email
from customizing import utilities
message_text = u'''This is an example message text!
It contains multiple lines!
And even some non ascii characters! Ä Ö Ü'''
email = utilities.SimpleEmail(subject='Example email',
from_address='you@yourcompany.com',
recipients=['someone@yourcompany.com'],
message_text=message_text)
email.send()