Skip to main content

Send email using Mailgun with Mailgun specific attributes.

Project description

Send email using Mailgun with Mailgun specific attributes.

It also includes an API-compatible send_mail function that allows you to pass custom Mailgun-specific attributes when sending email including:

  • campaign

  • deliverytime

  • dkim

  • track

  • tracking clicks

  • tracking opens

  • tags

Quick start

  1. Add “postgun” to INSTALLED_APPS:

INSTALLED_APPS = (
  ...
  'postgun'
)
  1. Add the following settings to your settings.py:

EMAIL_BACKEND = 'postgun.backends.MailgunEmailBackend'
MAILGUN_DOMAIN = 'example.com'
MAILGUN_API_KEY = 'key-my-api-key'
MAILGUN_PUBLIC_KEY = 'pubkey-my-public-key' #Only needed for email validation

Sending Email

from postman import send_mail
response_data = {}
send_mail('Test Email',  #subject
      'This is your test message.', #text content
      'admin@example.com',  #from address
      ['james@example.com', ],  #recipients
      html_message='This is your <strong>test</strong> message.', #html (optional)
      campaign='test',  #Mailgun campaign id
      tags=['testing', 'august', 'beta'],  #Mailgun tags - 3 max
      reply_to='jacob@example.com', #Reply to address
      response_data=response_data, #Variable to save response data from mailgun i.e. id and message
      )

Validating Email

Validate email checks against the Mailgun validation API to see if an address is valid.

If an address is invalid and there are no suggestions a ValidationError is raised. If an address is invalid and there are suggestions a ValidationError is raised with the suggestion in the message. Returns True on valid email or ConnectionError, AttributeErrors

from postman.validators import validate_email_mailgun
is_valid = validate_email_mailgun('james@hotmail.co.uk')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-postgun-0.2.tar.gz (7.2 kB view details)

Uploaded Source

File details

Details for the file django-postgun-0.2.tar.gz.

File metadata

  • Download URL: django-postgun-0.2.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for django-postgun-0.2.tar.gz
Algorithm Hash digest
SHA256 236c44f324fb86f175c24188ea4c59a753a9a973a062f60fffca3ea67ce76cd1
MD5 4e1065b26dc84cc1aa06260b065f383d
BLAKE2b-256 9e9fb5f9671a85737fdc2e546fc2c4288f511f482ca44fe864bf0ff0a4767d1a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page