{
"info": {
"author": "David Schrenker, Matt Reibach",
"author_email": "support@socketlabs.com",
"bugtrack_url": null,
"classifiers": [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7"
],
"description": "[](https://www.socketlabs.com) \n# [](https://twitter.com/socketlabs) [](./LICENSE) [](https://github.com/socketlabs/socketlabs-csharp/blob/master/CONTRIBUTING.md)\n\n\nThe SocketLabs Email Delivery Python library allows you to easily send email messages via the [SocketLabs Injection API](https://www.socketlabs.com/api-reference/injection-api/). The library makes it easy to build and send any type of message supported by the API, from a simple message to a single recipient all the way to a complex bulk message sent to a group of recipients with unique merge data per recipient.\n\n# Table of Contents\n* [Prerequisites and Installation](#prerequisites-and-installation)\n* [Getting Started](#getting-started)\n* [Managing API Keys](#managing-api-keys)\n* [Examples and Use Cases](#examples-and-use-cases)\n* [License](#license)\n\n\n\n# Prerequisites and Installation\n## Prerequisites\n* A supported Python version (3.4, 3.5, 3.6, 3.7)\n* A SocketLabs account. If you don't have one yet, you can [sign up for a free account](https://signup.socketlabs.com/step-1?plan=free) to get started.\n\n## Installation\n\n### pip\n```\npip install socketlabs-injectionapi\n```\n### From a local archive using pip\n\nYou can just download the package and install from a local archive file. \n\n> [socketlabs_injectionapi-1.0.0.tar.gz](https://github.com/socketlabs/socketlabs-python/releases/download/1.0.0/socketlabs_injectionapi-1.0.0.tar.gz)\n\n```\npip install /socketlabs_injectionapi-1.0.0.tar.gz\n```\n\n### From git using pip\n```\npip install git+https://github.com/socketlabs/socketlabs-python.git#egg=socketlabs_injectionapi\n```\nFor more information please see the [Installing Packages](https://packaging.python.org/tutorials/installing-packages/) tutorial\n\n\n# Getting Started\n## Obtaining your API Key and SocketLabs ServerId number\nIn order to get started, you'll need to enable the Injection API feature in the [SocketLabs Control Panel](https://cp.socketlabs.com). \nOnce logged in, navigate to your SocketLabs server's dashboard (if you only have one server on your account you'll be taken here immediately after logging in). \nMake note of your 4 or 5 digit ServerId number, as you'll need this along with \nyour API key in order to use the Injection API. \n\nTo enable the Injection API, click on the \"For Developers\" dropdown on the top-level navigation, then choose the \"Configure HTTP Injection API\" option. \nOnce here, you can enable the feature by choosing the \"Enabled\" option in the\ndropdown. Enabling the feature will also generate your API key, which you'll \nneed (along with your ServerId) to start using the API. Be sure to click the \n\"Update\" button to save your changes once you are finished.\n\n\n## Basic Message\nA basic message is an email message like you'd send from a personal email client such as Outlook. \nA basic message can have many recipients, including multiple To addresses, CC addresses, and even BCC addresses. \nYou can also send a file attachment in a basic message.\n\n```python\nfrom socketlabs.injectionapi import SocketLabsClient\nfrom socketlabs.injectionapi.message.basicmessage import BasicMessage\nfrom socketlabs.injectionapi.message.emailaddress import EmailAddress\n\n# Your SocketLabs ServerId and Injection API key\nclient = SocketLabsClient(10000, \"YOUR-API-KEY\");\n\nmessage = BasicMessage()\n\nmessage.subject = \"Sending A BasicMessage\"\nmessage.html_body = \"This is the Html Body of my message.\"\nmessage.plain_text_body = \"This is the Plain Text Body of my message.\";\n\nmessage.from_email_address = EmailAddress(\"from@example.com\")\n\n# A basic message supports up to 50 recipients \n# and supports several different ways to add recipients\n\n# Add a To address by passing the email address\nmessage.to_email_address.append(EmailAddress(\"recipient1@example.com\"))\nmessage.to_email_address.append(EmailAddress(\"recipient2@example.com\", \"Recipient #2\"))\n\n# // Adding CC Recipients\nmessage.add_cc_email_address(\"recipient3@example.com\")\nmessage.add_cc_email_address(\"recipient4@example.com\", \"Recipient #4\")\n\n# Adding Bcc Recipients\nmessage.add_bcc_email_address(EmailAddress(\"recipient5@example.com\"))\nmessage.add_bcc_email_address(EmailAddress(\"recipient6@example.com\", \"Recipient #6\"))\n\n\nresponse = client.send(message)\n```\n\n## Bulk Message\nA bulk message usually contains a single recipient per message \nand is generally used to send the same content to many recipients, \noptionally customizing the message via the use of MergeData. \nFor more information about using Merge data, please see the [Injection API documentation](https://www.socketlabs.com/api-reference/injection-api/#merging).\n```python\nfrom socketlabs.injectionapi import SocketLabsClient\nfrom socketlabs.injectionapi.message.bulkmessage import BulkMessage\nfrom socketlabs.injectionapi.message.bulkrecipient import BulkRecipient\nfrom socketlabs.injectionapi.message.emailaddress import EmailAddress\n\n# Your SocketLabs ServerId and Injection API key\nclient = SocketLabsClient(10000, \"YOUR-API-KEY\");\n\nmessage = BulkMessage()\n\nmessage.plain_text_body = \"This is the body of my message sent to %%Name%%\"\nmessage.html_body = \"This is the HtmlBody of my message sent to %%Name%%\"\nmessage.subject = tests\nmessage.from_email_address = EmailAddress(\"from@example.com\")\n\nrecipient1 = BulkRecipient(\"recipient1@example.com\")\nrecipient1.add_merge_data(\"Name\", \"Recipient1\")\nmessage.add_to_recipient(recipient1)\n\nrecipient2 = BulkRecipient(\"recipient2@example.com\", \"Recipient #2\")\nrecipient2.add_merge_data(\"Name\", \"Recipient2\")\nmessage.add_to_recipient(recipient2)\n\nresponse = client.send(message)\n```\n\n\n## Managing API Keys\nFor ease of demonstration, many of our examples include the ServerId (SOCKETLABS_SERVER_ID) and API key \n(SOCKETLABS_INJECTION_API_KEY) directly in our code sample. Generally it is not considered a good practice to store \nsensitive information like this directly in your code. Depending on your project type, we recommend either storing your \ncredentials using Environment Variables. For more information please see: \n[Using Environment Variables](https://docs.microsoft.com/en-us/dotnet/api/system.environment.getenvironmentvariable)\n\n\n\n# Examples and Use Cases\nIn order to demonstrate the many possible use cases for the SDK, we've provided \nan assortment of code examples. These examples demonstrate many different \nfeatures available to the Injection API and SDK, including using templates \ncreated in the [SocketLabs Email Designer](https://www.socketlabs.com/blog/introducing-new-email-designer/), custom email headers, sending \nattachments, sending content that is stored in an HTML file, advanced bulk \nmerging, and even pulling recipients from a datasource.\n\n### [Basic send example](https://github.com/socketlabs/socketlabs-python/blob/master/python-examples/basic/basic_send.py)\nThis example demonstrates a Basic Send.\n\n### [Basic send async example](https://github.com/socketlabs/socketlabs-python/blob/master/python-examples/basic/basic_async.py)\nBasic send async example\n\n### [Basic send complex example](https://github.com/socketlabs/socketlabs-python/blob/master/python-examples/basic/basic_send_complex.py)\nThis example demonstrates many features of the Basic Send, including adding multiple recipients, adding message and mailing id's, and adding an embedded image.\n\n### [Basic send from HTML file](https://github.com/socketlabs/socketlabs-python/blob/master/python-examples/basic/basic_send_from_html_file.py)\nThis example demonstrates how to read in your HTML content from an HTML file \nrather than passing in a string directly.\n\n### [Basic send from SocketLabs Template](https://github.com/socketlabs/socketlabs-python/blob/master/python-examples/basic/basic_send_with_api_template.py)\nThis example demonstrates the sending of a piece of content that was created in the \nSocketLabs Email Designer. This is also known as the [API Templates](https://www.socketlabs.com/blog/introducing-api-templates/) feature.\n\n### [Basic send with specified character set](https://github.com/socketlabs/socketlabs-python/blob/master/python-examples/basic/basic_send_with_ascii_charset.py)\nThis example demonstrates sending with a specific character set.\n\n### [Basic send with file attachment](https://github.com/socketlabs/socketlabs-python/blob/master/python-examples/basic/basic_send_with_attachment.py)\nThis example demonstrates how to add a file attachment to your message.\n\n### [Basic send with custom email headers](https://github.com/socketlabs/socketlabs-python/blob/master/python-examples/basic/basic_send_with_custom_headers.py)\nThis example demonstrates how to add custom headers to your email message.\n\n### [Basic send with embedded image](https://github.com/socketlabs/socketlabs-python/blob/master/python-examples/basic/basic_send_with_embedded_image.py)\nThis example demonstrates how to embed an image in your message.\n\n### [Basic send with a web proxy](https://github.com/socketlabs/socketlabs-python/blob/master/python-examples/basic/basic_send_with_proxy.py)\nThis example demonstrates how to use a proxy with your HTTP client.\n\n### [Basic send with invalid file attachment](https://github.com/socketlabs/socketlabs-python/blob/master/python-examples/basic/invalid/basic_send_with_invalid_attachment.py)\nThis example demonstrates the results of attempting to do a send with an invalid attachment.\n\n### [Basic send with invalid from address](https://github.com/socketlabs/socketlabs-python/blob/master/python-examples/basic/invalid/basic_send_with_invalid_from.py)\nThis example demonstrates the results of attempting to do a send with an invalid from address.\n\n### [Basic send with invalid recipients](https://github.com/socketlabs/socketlabs-python/blob/master/python-examples/basic/invalid/basic_send_with_invalid_recipients.py)\nThis example demonstrates the results of attempting to do a send with invalid recipients.\n\n### [Bulk send with multiple recipients](https://github.com/socketlabs/socketlabs-python/blob/master/python-examples/bulk/bulk_send.py)\nThis example demonstrates how to send a bulk message to multiple recipients.\n\n### [Bulk send with merge data](https://github.com/socketlabs/socketlabs-python/blob/master/python-examples/bulk/bulk_send_from_data_source_with_merge.py)\nThis example demonstrates how to send a bulk message to multiple recipients with \nunique merge data per recipient.\n\n### [Bulk send with complex merge including attachments](https://github.com/socketlabs/socketlabs-python/blob/master/python-examples/bulk/bulk_send_complex.py)\nThis example demonstrates many features of the `BulkMessage()`, including \nadding multiple recipients, merge data, and adding an attachment.\n\n### [Bulk send with recipients pulled from a datasource](https://github.com/socketlabs/socketlabs-python/blob/master/python-examples/bulk/bulk_send_with_ascii_charset_merge_data.py)\nThis example uses a mock repository class to demonstrate how you would pull \nyour recipients from a database and create a bulk mailing with merge data.\n\n### [Bulk send with Ascii charset and special characters](https://github.com/socketlabs/socketlabs-python/blob/master/python-examples/bulk/bulk_send_with_ascii_charset_merge_data.py)\nThis example demonstrates how to send a bulk message with a specified character \nset and special characters.\n\n\n\n# License\nThe SocketLabs.EmailDelivery library and all associated code, including any code samples, are [MIT Licensed](https://github.com/socketlabs/socketlabs-python/blob/master/LICENSE.MD).",
"description_content_type": "text/markdown",
"docs_url": null,
"download_url": "",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://github.com/socketlabs/socketlabs-python",
"keywords": "",
"license": "MIT",
"maintainer": "",
"maintainer_email": "",
"name": "socketlabs-injectionapi",
"package_url": "https://pypi.org/project/socketlabs-injectionapi/",
"platform": "",
"project_url": "https://pypi.org/project/socketlabs-injectionapi/",
"project_urls": {
"Bug Reports": "https://github.com/socketlabs/socketlabs-python/issues",
"Homepage": "https://github.com/socketlabs/socketlabs-python",
"License": "https://github.com/socketlabs/socketlabs-python/blob/master/LICENSE",
"Organization": "https://github.com/socketlabs",
"Source": "https://github.com/socketlabs/socketlabs-python"
},
"release_url": "https://pypi.org/project/socketlabs-injectionapi/1.0.1/",
"requires_dist": null,
"requires_python": "",
"summary": "SocketLabs Email Delivery Python client library",
"version": "1.0.1"
},
"last_serial": 4491252,
"releases": {
"1.0.0": [
{
"comment_text": "",
"digests": {
"md5": "97af290fc0f003102cdeed3f145adbb3",
"sha256": "c3bb3a95af26cc0f7781050221dd6d13a4a8fbd69e0ed42b91a91fd9609513d3"
},
"downloads": -1,
"filename": "socketlabs_injectionapi-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "97af290fc0f003102cdeed3f145adbb3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 28883,
"upload_time": "2018-11-15T18:28:04",
"url": "https://files.pythonhosted.org/packages/30/ab/44c1ae8015f59b926e79a799bd31e36d77ac00c029ae5adeb6facf145bfd/socketlabs_injectionapi-1.0.0.tar.gz"
}
],
"1.0.1": [
{
"comment_text": "",
"digests": {
"md5": "50b97bfcd0330935e3468cb84042d1c7",
"sha256": "0cb6840057831485802e06ea8ad9a8632161f52eaa088aa04364e769b13f491a"
},
"downloads": -1,
"filename": "socketlabs_injectionapi-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "50b97bfcd0330935e3468cb84042d1c7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 29194,
"upload_time": "2018-11-15T21:13:58",
"url": "https://files.pythonhosted.org/packages/07/6a/4ad80c459dbbfa96c0ccfe9e94b33720276cebd525e74ffcec508f60f52e/socketlabs_injectionapi-1.0.1.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "50b97bfcd0330935e3468cb84042d1c7",
"sha256": "0cb6840057831485802e06ea8ad9a8632161f52eaa088aa04364e769b13f491a"
},
"downloads": -1,
"filename": "socketlabs_injectionapi-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "50b97bfcd0330935e3468cb84042d1c7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 29194,
"upload_time": "2018-11-15T21:13:58",
"url": "https://files.pythonhosted.org/packages/07/6a/4ad80c459dbbfa96c0ccfe9e94b33720276cebd525e74ffcec508f60f52e/socketlabs_injectionapi-1.0.1.tar.gz"
}
]
}