Django

Configure Django's built-in SMTP backend to send through Unitpost.

What are the SMTP settings?

Hostsmtp.unitpost.com
Usernameunitpost(always this literal value)
PasswordYour Unitpost API key(must carry emails:send)
Port (STARTTLS)587(or 2587 if blocked)
Port (implicit TLS)465(or 2465 if blocked)
From addressAny address on a verified domain

How do I set it up?

  1. Configure your settings

    Add the SMTP settings to settings.py. Keep the API key in an environment variable.

    Python
    EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
    EMAIL_HOST = "smtp.unitpost.com"
    EMAIL_PORT = 587
    EMAIL_USE_TLS = True
    EMAIL_HOST_USER = "unitpost"
    EMAIL_HOST_PASSWORD = os.environ["UNITPOST_API_KEY"]
    DEFAULT_FROM_EMAIL = "you@yourdomain.com"
  2. Send an email

    Use send_mail or an EmailMessage. The from address must be on a verified domain.

    Python
    from django.core.mail import send_mail
    
    send_mail(
        subject="Hello from Unitpost",
        message="Sent via SMTP.",
        from_email="you@yourdomain.com",
        recipient_list=["customer@example.com"],
        html_message="<h1>Welcome!</h1>",
    )
  3. Verify delivery

    Check your Unitpost Activity view for the message and its status.