Mailing
Mailing is a crucial part of any project, especially for startups. We designed it to be highly flexible yet ready to use out of the box. Predefined email templates ensure you gain valuable feedback and remain proactive with your users. Emails are sent in the following situations:
- New User Creation - Welcome email to the user.
- New Purchase - Confirmation and details of the purchase.
- Invoice Data - Sends the invoice and additional purchase details.
- Subscription Cancellation - Requests feedback on why the subscription was canceled.
- Invitation - Invitation to join an organization.
- Validation Email - Sent when validation for new users is required.
- Password Reset - Sent when a user requests a password reset.
The mailer
app is responsible for managing all email functionalities. Emails are sent
asynchronously using Celery, so make sure to run the Celery worker before starting.
Templates
Email templates can be easily customized by editing files in the mailer/templates
directory. Each email includes both .txt
and .html
versions to ensure proper formatting, even for clients that block HTML.
Explore awesome email template ideas and learn how to implement them easily in the guidebook.
Each template is automatically populated with “common” data, which can be prepared using a dedicated method in the MailerService
:
Sending Emails
You can use your own SMTP server or integrate with Mailgun for sending emails. Ensure the DEFAULT_EMAIL_PROVIDER
environment variable is set correctly.
After setting the email provider, test the email sending functionality using the following Django command:
SMTP
To configure SMTP, set smtp
as the value of the DEFAULT_EMAIL_PROVIDER
variable. Additionally, provide the following SMTP client details in your environment variables file:
SMTP_SERVER
SMTP_USERNAME
SMTP_PORT
SMTP_PASSWORD
Mailgun
To use Mailgun, set mailgun
as the value of the DEFAULT_EMAIL_PROVIDER
variable and provide the following details for integration:
MAILGUN_API_KEY
- Obtain your key by creating an account in Mailgun and navigating to API Security → Add New Key.MAILGUN_POST_URL
- Construct the URL as follows:https://api.mailgun.net/v3/YOUR_DOMAIN_NAME/messages
ReplaceYOUR_DOMAIN_NAME
with your actual domain name.