Django wrapper for interfacing with e-Mail as a Service providers.
pip install maas==1.3.2
pip install maas
python manage.py migrate
MAAS = {
'DEFAULT_SENDER': 'default_sender@mailprovider.com',
'DEFAULT_SENDER_TITLE': 'Default Sender'
}
In your settings.py
, add the following:
MAAS = {
'PROVIDER': 'MAILGUN_V3',
'DOMAIN': 'your.configured.domain',
'API_KEY': 'YOUR_API_KEY',
'OPTIONS': {
'context_processors': [
'your_module.your_context_processing_function'
]
}
}
from maas.models import Mail
mail = Mail(
sender='sender@domain.com',
sender_title='Sender From Domain.com',
recipient='recipient@domain.com',
subject='Test Subject',
body='Test Body'
)
from maas.models import Mail
mail = Mail(
sender='sender@domain.com',
sender_title='Sender From Domain.com',
recipient='recipient@domain.com',
subject='Test Subject',
template='template_to_load.html', # uses Django template loader
context={ # context is optional
'context': 'passed to template'
}
)
To send mail, run mail.send()
. Note that this will also trigger mail.send()
once the message has been successfully sent.