Ejemplo n.º 1
0
from socketlabs.injectionapi import SocketLabsClient
from socketlabs.injectionapi.message.__imports__ import \
    BasicMessage, EmailAddress


# build the message
message = BasicMessage()

message.subject = "Sending A Test Message (Basic Send)"
message.html_body = "<html><body>" \
                    "<h1>Sending A Test Message</h1>" \
                    "<p>This is the Html Body of my message.</p>" \
                    "</body></html>"
message.plain_text_body = "This is the Plain Text Body of my message."

message.from_email_address = EmailAddress("*****@*****.**")
message.add_to_email_address("*****@*****.**")
message.add_to_email_address("*****@*****.**", "Recipient #2")
message.add_to_email_address(EmailAddress("*****@*****.**"))
message.add_to_email_address(EmailAddress("*****@*****.**", "Recipient #4"))


# get credentials from environment variables
server_id = int(os.environ.get('SOCKETLABS_SERVER_ID'))
api_key = os.environ.get('SOCKETLABS_INJECTION_API_KEY')

# create the client
client = SocketLabsClient(server_id, api_key)

# send the message
response = client.send(message)
Ejemplo n.º 2
0
from socketlabs.injectionapi import SocketLabsClient
from socketlabs.injectionapi.message.__imports__ import \
    BulkMessage, BulkRecipient, EmailAddress

# build the message
message = BulkMessage()

message.subject = "Sending A Test Message (Bulk Send)"
message.html_body = "<html><body>" \
                    "<h1>Sending A Test Message</h1>" \
                    "<p>This is the Html Body of my message.</p>" \
                    "</body></html>"
message.plain_text_body = "This is the Plain Text Body of my message."

message.from_email_address = EmailAddress("*****@*****.**")
message.add_to_recipient("*****@*****.**")
message.add_to_recipient("*****@*****.**", "Recipient #2")
message.add_to_recipient(BulkRecipient("*****@*****.**"))
message.add_to_recipient(
    BulkRecipient("*****@*****.**", "Recipient #4"))

# get credentials from environment variables
server_id = int(os.environ.get('SOCKETLABS_SERVER_ID'))
api_key = os.environ.get('SOCKETLABS_INJECTION_API_KEY')

# create the client
client = SocketLabsClient(server_id, api_key)

# send the message
response = client.send(message)
Ejemplo n.º 3
0
import os

from socketlabs.injectionapi import SocketLabsClient
from socketlabs.injectionapi.message.__imports__ import \
    BasicMessage, EmailAddress

# build the message
message = BasicMessage()

message.subject = "Sending A Test Message"
message.html_body = "<html><body>" \
                    "<h1>Sending A Test Message</h1>" \
                    "<p>This is the Html Body of my message.</p>" \
                    "</body></html>"
message.plain_text_body = "This is the Plain Text Body of my message."

message.from_email_address = EmailAddress("!@#$!@#$!@#$@#!$")
message.add_to_email_address("*****@*****.**")

# get credentials from environment variables
server_id = int(os.environ.get('SOCKETLABS_SERVER_ID'))
api_key = os.environ.get('SOCKETLABS_INJECTION_API_KEY')

# create the client
client = SocketLabsClient(server_id, api_key)

# send the message
response = client.send(message)

print(json.dumps(response.to_json(), indent=2))
Ejemplo n.º 4
0
                   "    <head>" \
                   "    <meta charset=\"utf-8\">" \
                   "     <script async src=\"https://cdn.ampproject.org/v0.js\"></script>" \
                   "    <style amp4email-boilerplate>body{visibility:hidden}</style>" \
                   "     <style amp-custom>" \
                   "         h1 {" \
                   "              margin: 1rem;" \
                   "            }" \
                   "      </style>" \
                   "   </head>" \
                   "        <body>" \
                   "         <h1>This is the AMP Html Body of my message</h1>" \
                   "        </body>" \
                   "</html>"

message.from_email_address = EmailAddress("*****@*****.**")
message.reply_to_email_address = EmailAddress("*****@*****.**")

# Adding To Recipients
# ==========================
# Add EmailAddresses using a list
to_recipients = [
    EmailAddress("*****@*****.**"),
    EmailAddress("*****@*****.**", "Recipient #2")
]
message.to_email_address = to_recipients

# Add EmailAddresses using the add_to_email_address function
message.add_to_email_address(
    EmailAddress("*****@*****.**", "Recipient #3"))
message.add_to_email_address("*****@*****.**")
from socketlabs.injectionapi import SocketLabsClient
from socketlabs.injectionapi.message.__imports__ import \
    BasicMessage, EmailAddress

# build the message
message = BasicMessage()

message.subject = "Sending A Test Message"
message.html_body = "<html><body>" \
                    "<h1>Sending A Test Message</h1>" \
                    "<p>This is the Html Body of my message.</p>" \
                    "</body></html>"
message.plain_text_body = "This is the Plain Text Body of my message."

message.from_email_address = EmailAddress("*****@*****.**")

# good
message.to_email_address.append(EmailAddress("*****@*****.**"))

# invalid
message.to_email_address.append(EmailAddress("!@#$!@#$!@#$@#!$"))
message.to_email_address.append(EmailAddress("failure.com"))
message.to_email_address.append(EmailAddress("ImMissingSomething"))
message.to_email_address.append(EmailAddress("Fail@@!.Me"))

# get credentials from environment variables
server_id = int(os.environ.get('SOCKETLABS_SERVER_ID'))
api_key = os.environ.get('SOCKETLABS_INJECTION_API_KEY')

# create the client
Ejemplo n.º 6
0
from socketlabs.injectionapi import SocketLabsClient
from socketlabs.injectionapi.message.__imports__ import \
    BasicMessage, EmailAddress

# build the message
message = BasicMessage()

message.subject = "Sending A Test Message"
message.html_body = "<html><body>" \
                    "<h1>Sending A Test Message</h1>" \
                    "<p>This is the Html Body of my message.</p>" \
                    "</body></html>"
message.plain_text_body = "This is the Plain Text Body of my message."

message.from_email_address = EmailAddress("*****@*****.**")
message.reply_to_email_address = EmailAddress("!@#$!@#$!@#$@#!$")
message.add_to_email_address("*****@*****.**")

# get credentials from environment variables
server_id = int(os.environ.get('SOCKETLABS_SERVER_ID'))
api_key = os.environ.get('SOCKETLABS_INJECTION_API_KEY')

# create the client
client = SocketLabsClient(server_id, api_key)

# send the message
response = client.send(message)

print(json.dumps(response.to_json(), indent=2))
                 "           Motto = <b>%%Motto%%</b> </br>"\
                 "           Birthday = <b>%%Birthday%%</b> </br>"\
                 "           Age = <b>%%Age%%</b> </br>"\
                 "           UpSell = <b>%%UpSell%%</b>"\
                 "       </p>"\
                 "       <h2>Example of Merge Usage</h2>"\
                 "       <p>"\
                 "           Our company motto is '<b>%%Motto%%</b>'. </br>"\
                 "           Your birthday is <b>%%Birthday%%</b> and you are <b>%%Age%%</b> years old."\
                 "       </p>"\
                 "       <h2>UTF-8 Characters:</h2>"\
                 "       <p>✔ - Check</p>"\
                 "       </body>"\
                 "       </html>"

message.from_email_address = EmailAddress("*****@*****.**", "FromMe")
message.reply_to_email_address = EmailAddress("*****@*****.**")


# Add some global merge-data
# (These will be applied to all Recipients unless specifically overridden by Recipient level merge data)
# ==========================
# Add global merge data using a dictionary
global_merge_data = {
        "Motto": "When hitting the inbox matters!",
        "Birthday": "unknown"
    }
message.global_merge_data = global_merge_data

# Add global merge data directly to the dictionary on the message
message.global_merge_data["Age"] = "an unknown number of"