Skip to main content

API wrapper for MailRelay written in Python

Project description

python-mailrelay

python-mailrelay is an API wrapper for Mailrelay written in Python.

Installing

pip install mailrelay-python

Before start

To use Mailrelay Python, go user dashboard anf get the API KEY

Usage

Client instantiation

from mailrelay.client import Client as Client
client = Client((api_key=api_key, url=url))

Mailrelay Workflow

Get Groups

response = client.get_groups()
Returns:
        list: [
        {
            "id": 1,
            "name": "grupo test 1",
            "description": "",
            "subscribers_count": 3,
            "created_at": "2022-05-11T22:48:18.000Z",
            "updated_at": "2022-05-11T22:48:18.000Z",
        },
        {
            "id": 2,
            "name": "grupo 2",
            "description": "",
            "subscribers_count": 1,
            "created_at": "2022-05-20T15:38:13.000Z",
            "updated_at": "2022-05-20T15:38:13.000Z",
        },
    ]

Get Campaigns

response = client.get_campaigns()

 Returns:
        [
            {
                "id": 0,
                "subject": "string",
                "sender_id": 0,
                "campaign_folder_id": 0,
                "target": "groups",
                "segment_id": 0,
                "group_ids": "string",
                "preview_text": "string",
                "html": "string",
                "editor_type": "html",
                "url_token": false,
                "analytics_utm_campaign": "string",
                "use_premailer": false
            }
        ]


Send Campaigns

response = client.send_campaigns(id, data)

Get Subscribers

response = client.get_subscribers()

Returns:
            list:
            [
                {
                    "id": 1,
                    "email": "juantest@gmail.com",
                    "name": "juan",
                    "score": None,
                    "status": "active",
                    "subscribed_at": None,
                    "subscribed_with_acceptance": False,
                    "subscribe_ip": None,
                    "unsubscribed": False,
                    "unsubscribed_at": None,
                    "unsubscribe_ip": None,
                    "unsubscribe_sent_email_id": None,
                    "address": "",
                    "city": "",
                    "state": "",
                    "country": "",
                    "birthday": None,
                    "website": "",
                    "time_zone": "",
                    "locale": "",
                    "bounced": False,
                    "reported_spam": False,
                    "local_ban": False,
                    "global_ban": False,
                    "created_at": "2022-05-11T22:15:02.000Z",
                    "updated_at": "2022-05-11T22:15:02.000Z",
                    "custom_fields": {},
                },
            ]

Get Subscriber by id

response = client.get_subscriber_by_id(id)

Returns:
            dict: {
                "id": 0,
                "email": "user@example.com",
                "name": "string",
                "score": 0,
                "status": "string",
                "subscribed_at": "1970-01-01T00:00:00.000Z",
                "subscribed_with_acceptance": false,
                "subscribe_ip": "198.51.100.42",
                "unsubscribed": false,
                "unsubscribed_at": "1970-01-01T00:00:00.000Z",
                "unsubscribe_ip": "198.51.100.42",
                "unsubscribe_sent_email_id": 0,
                "address": "string",
                "city": "string",
                "state": "string",
                "country": "string",
                "birthday": "1970-01-01",
                "website": "string",
                "time_zone": "Africa/Abidjan",
                "locale": "en",
                "bounced": false,
                "reported_spam": false,
                "local_ban": false,
                "global_ban": false,
                "created_at": "1970-01-01T00:00:00.000Z",
                "updated_at": "1970-01-01T00:00:00.000Z",
                "groups": [
                    {
                    "group_id": 0,
                    "assigned_at": "1970-01-01T00:00:00.000Z"
                    }
                ],
                "custom_fields": {}
                }

Create Subscriber

response = client.create_subscriber(data)

Delete Subscriber

response = client.delete_subscriber(id)

Requirements

  • requests

Contributing

We are always grateful for any kind of contribution including but not limited to bug reports, code enhancements, bug fixes, and even functionality suggestions.

You can report any bug you find or suggest new functionality with a new issue.

If you want to add yourself some functionality to the wrapper:

  1. Fork it ( https://github.com/GearPlug/mailrelay-python )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Adds my new feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

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

mailrelay_python-1.0.4.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

mailrelay_python-1.0.4-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file mailrelay_python-1.0.4.tar.gz.

File metadata

  • Download URL: mailrelay_python-1.0.4.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for mailrelay_python-1.0.4.tar.gz
Algorithm Hash digest
SHA256 acb38d7092b88e2095eff046fd921cc15922ccf347b3bdbbd0fc80c19d8b0731
MD5 62067c08c18299ca298850ecaa7e4219
BLAKE2b-256 76d91c05a6086af20af5b321b3a02fa424b82ba697e334572f76d71791d96dca

See more details on using hashes here.

File details

Details for the file mailrelay_python-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for mailrelay_python-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 846d1769b4246f7ba1176dfab07eebc876363f91123b580dfa72e9267f4c6c6e
MD5 d0d0e0d4c7fab15701684dbde9ee0179
BLAKE2b-256 0a1fc1482ec09be2b792d82b8e1dd87ac1d772bc0da9c2d2ddd7c98832e25399

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