connection for sending this email as typically only some emails in a project will be sent through Loops.
Add these settings to your project (e.g. in an .env file).
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
Send transactional emails from your Django project using Loops’ SMTP service.
connection for each email request that you want to send through Loops.connection for sending this email as typically only some emails in a project will be sent through Loops.
Add these settings to your project (e.g. in an .env file).
| Field | Value |
|---|---|
| Host | smtp.loops.so |
| Port number | 587 |
| Username | loops |
| Password | An API key copied from your API settings in Loops |
transactionalId value in the email payload.from django.core.mail import send_mail, get_connection
import json
import os
with get_connection(
host=os.environ['LOOPS_SMTP_HOST'],
port=os.environ['LOOPS_SMTP_PORT'],
username=os.environ['LOOPS_SMTP_USER'],
password=os.environ['LOOPS_SMTP_PASSWORD'],
use_tls=True # Has to be True
) as connection:
email = 'test@example.com'
# This payload can be copied from a transactional email's
# Publish page in Loops
payload = {
"transactionalId": "clomzp89u635xl30px7wrl0ri",
"email": email,
"dataVariables": {
"buttonUrl": "https://myapp.com/login/",
"userName": "Bob"
}
}
send_mail(
"Subject here", # Overwritten by Loops template
json.dumps(payload), # Stringify the payload
"test@example.com", # Overwritten by Loops template
[email],
fail_silently=False,
connection=connection
)
Was this page helpful?
