This package lets you send emails from a Python context.
Functions
Reading mail related global settings
|
Function |
Parameters |
Return Value |
Description |
|---|---|---|---|
|
get_smtp_server_address() |
|
String |
Returns the value of the smtp server address global setting |
|
get_smtp_server_port() |
|
String |
Returns the value of the smtp server port global setting |
|
get_default_email_sender() |
|
String |
Returns the value of the default email sender global setting |
|
get_smtp_username() |
|
String |
Returns the value of the smtp username global setting |
|
get_smtp_password() |
|
String |
Returns the value of the smtp password global setting |
Reading mail related user data
|
Function |
Parameters |
Return Value |
Description |
|---|---|---|---|
|
get_user_email( |
user: user id from DI 010323 in 511 |
String or |
Returns the value of the users email address or |
Creating a new message object
See the Python docs for documentation on the EmailMessage class: https://docs.python.org/3/library/email.message.html
|
Function |
Parameters |
Return Value |
Description |
|---|---|---|---|
|
get_default_message() |
|
|
Creates a default |
|
get_default_text_message( |
recipient: string containing the email address of the recipient. If you have multiple recipients you can use a string containing a comma separated list of addresses. subject: string subject of the email. content: string The text body of the email |
|
Creates a default |
|
get_default_html_message( |
recipient: string containing the email address of the recipient. If you have multiple recipients you can use a string containing a comma separated list of addresses. subject: string subject of the email. content: string The html body of the email |
|
Creates a html |
Classes
EmailContext
Methods
|
Function |
Parameters |
Return Value |
Description |
|---|---|---|---|
|
EmailContext.__init__( |
user: Optional user to use as authentication against the smtp server If password: Optional password to use as authentication against the smtp server. If None is used the smtp username global setting is read and used. |
|
Initialize a new |
|
EmailContext.__enter__( |
|
|
Connect to the SMTP server and optionally authenticate with the server if the parameters were set. |
|
EmailContext.__exit__( |
exc_type: Exception type. exc_val: Exception value. exc_tb: Exception traceback |
|
Disconnect from the SMTP server |
|
EmailContext.send_message( |
message: |
returns the result of https://docs.python.org/3/library/smtplib.html#smtplib.SMTP.send_message |
Send a |
Example Code
Sending a mail to multiple recipients using the EmailContext context manager
from ppms.customizer import mail
recipient_list = ['customizer1@example.com', 'customizer2@example.com']
recipient = ','.join(recipient_list)
subject = 'E-Mail Sending Example'
content = 'Hello World!'
message = mail.get_default_text_message(recipient=recipient, subject=subject, content=content)
with mail.EmailContext() as m:
response = m.send_message(message=message)
- Global Settings (Project) MOD009DJ5
- Global Settings (Project) MOD009DJ5
- Global Settings (Project) MOD009DJ5
- Global Settings (Project) MOD009DJ5
- Global Settings (Project) MOD009DJ5
- Global Settings (Project) MOD009DJ5
- Global Settings (Project) MOD009DJ5
- Global Settings (Project) MOD009DJ5
- Global Settings (Project) MOD009DJ5
- Globale Einstellungen (Projekt) MOD009DJ5
- Globale Einstellungen (Projekt) MOD009DJ5
- Globale Einstellungen (Projekt) MOD009DJ5
- Globale Einstellungen (Projekt) MOD009DJ5
- Globale Einstellungen (Projekt) MOD009DJ5
- Globale Einstellungen (Projekt) MOD009DJ5
- Globale Einstellungen (Projekt) MOD009DJ5
- Globale Einstellungen (Projekt) MOD009DJ5
- Globale Einstellungen (Projekt) MOD009DJ5
- Globale Einstellungen (Projekt) MOD009DJ5