Skip to main content

This is the Amply Python SDK that integrates with the v1 API.

Project description

Amply

This is the Amply Python SDK that integrates with the v1 API.

Table of Contents

Install

Prerequisites

Access Token

Obtain your access token from the Amply UI.

Install Package

pip install amply-mail

Domain Verification

Add domains you want to send from via the Verified Domains tab on your dashboard.

Any emails you attempt to send from an unverified domain will be rejected. Once verified, Amply immediately starts warming up your domain and IP reputation. This warmup process will take approximately one week before maximal deliverability has been reached.

Quick Start

The following is the minimum needed code to send a simple email. Use this example, and modify the to and from variables:

import amply
import os

amply.set_access_token(os.environ.get('AMPLY_ACCESS_TOKEN'))

try:
    response = amply.email.create({
        'to': 'test@example.com',
        'from': 'test@verifieddomain.com',
        'subject': 'My first Amply email!',
        'text': 'This is easy',
        'html': '<strong>and fun :)</strong>'
    })
except Exception as e:
    if hasattr(e, 'errors'):
        print('Validation or resource not found error')
        print(e.errors)
    elif hasattr(e, 'text'):
        print('Generic API error: %s' %(e.text))
    else:
        raise e

Once you execute this code, you should have an email in the inbox of the recipient. You can check the status of your email in the UI from the Search, SQL, or Users page.

Methods

email

Parameter(s) Description
to, cc, bcc Email address of the recipient(s). This may be a string Test <test@example.com>, an object {name: 'Test', email: 'test@example.com'}, or an array of strings and objects.
personalizations For fine tuned access, you may override the to, cc, and bcc keys and use advanced personalizations. See the API guide here.
from Email address of the sender. This may be formatted as a string or object. An array of senders is not allowed.
subject Subject of the message.
html HTML portion of the message.
text Text portion of the message.
content An array of objects containing the following keys: type (required), value (required).
template The template to use. This may be a string (the UUID of the template), an array of UUID's (useful for A/B/... testing where one is randomly selected), or an object of the format {template1Uuid: 0.25, template2Uuid: 0.75} (useful for weighted A/B/... testing).
dynamic_template_data The dynamic data to be replaced in your template. This is an object of the format {variable1: 'replacement1', ...}. Variables should be defined in your template body using handlebars syntax {{variable1}}.
reply_to Email address of who should receive replies. This may be a string or an object with name and email keys.
headers An object where the header name is the key and header value is the value.
ip_or_pool_uuid The UUID of the IP address or IP pool you want to send from. Default is your Global pool.
unsubscribe_group_uuid The UUID of the unsubscribe group you want to associate with this email.
attachments[][content] A base64 encoded string of your attachment's content.
attachments[][type] The MIME type of your attachment.
attachments[][filename] The filename of your attachment.
attachments[][disposition] The disposition of your attachment (inline or attachment).
attachments[][content_id] The content ID of your attachment.
clicktracking Enable or disable clicktracking.
categories An array of email categories you can associate with your message.
substitutions An object of the format {subFrom: 'subTo', ...} of substitutions.
send_at Delay sending until a specified time. An ISO8601 formatted string with timezone information.

Example

amply.email.create({
    'to':   'example@test.com',
    'from': 'From <example@verifieddomain.com>',
    'text': 'Text part',
    'html': 'HTML part',
    'personalizations': [{'to': [{'name': 'Override To', 'email': 'test@example.com'}]}],
    'content': [{'type': 'text/testing', 'value': 'some custom content type'}],
    'subject': 'A new email!',
    'reply_to': 'Reply To <test@example.com>',
    'template': 'faecb75b-371e-4062-89d5-372b8ff0effd',
    'dynamic_template_data': {'name': 'Jimmy'},
    'unsubscribe_group_uuid': '5ac48b43-6e7e-4c51-817d-f81ea0a09816',
    'ip_or_pool_uuid': '2e378fc9-3e23-4853-bccb-2990fda83ca9',
    'attachments': [{'content': 'dGVzdA==', 'filename': 'test.txt', 'type': 'text/plain', 'disposition': 'inline'}],
    'headers': {'X-Testing': 'Test'},
    'categories': ['Test'],
    'clicktracking': True,
    'substitutions': {'sub1': 'replacement1'},
    'send_at': datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc).isoformat()
})

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

amply-mail-0.0.1rc2.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

amply_mail-0.0.1rc2-py2.py3-none-any.whl (9.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file amply-mail-0.0.1rc2.tar.gz.

File metadata

  • Download URL: amply-mail-0.0.1rc2.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.1

File hashes

Hashes for amply-mail-0.0.1rc2.tar.gz
Algorithm Hash digest
SHA256 9b2fa8a426bc3b32f56bc47398b25fd4a55f21a64e6305e0e02eca2e71a04e3b
MD5 b1cfb05085414b75f07e2523b6f080fc
BLAKE2b-256 fbd0b7f0f3dc1db6a54352c23b4c283ffa0e6ed52a30cf19fcb6f3dcab6a770d

See more details on using hashes here.

File details

Details for the file amply_mail-0.0.1rc2-py2.py3-none-any.whl.

File metadata

  • Download URL: amply_mail-0.0.1rc2-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.1

File hashes

Hashes for amply_mail-0.0.1rc2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 03b90fb9e7bd9aa20ae0ad42cbf9831a954a5585788f542e162d8fab03bde0f9
MD5 986a6a9500694cf304dd64b80e80a0ec
BLAKE2b-256 b819de19f71244ae708d7e8b6ecc25511585a5cc6c89b656956495d8591cd523

See more details on using hashes here.

Supported by

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