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

FunctionParametersReturn ValueDescription
_Email.send(self)

Sends the email using the SMTP server configured in smtp_server_adress

SimpleEmail

Methods

FunctionParametersReturn ValueDescription
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 instanceInitializes a new SimpleEmail object

HtmlEmail

Methods

FunctionParametersReturn ValueDescription
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 instanceInitializes 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()
PY