示例#1
0
def send_email():
    message = {
        'rcpt_name': 'Tim',
        'rcpt_email': '*****@*****.**',
        'sender_name': 'Bob',
        'sender_email': '*****@*****.**',
        'plaintext_body': 'Plain text body',
        'some_key': 'some text value'
    }
    templates_client = MessageBusTemplatesClient(api_key, uri=uri)
    try:
        result = templates_client.send_messages(template=template_key,
                                                messages=[message])
    except MessageBusResponseError, error:
        print error.message
def create_template():
    template = {
        "to_name": "{{rcpt_name}}",
        "to_email": "{{rcpt_email}}",
        "from_name": "{{sender_name}}",
        "from_email": "{{sender_email}}",
        "return_path": "*****@*****.**",
        "custom_headers": {
            "x-messagebus-sdk": "py"
        },
        "subject": "Hey! {{rcpt_name}}",
        "plaintext_body": "Plain text content",
        "html_body": "<HTML>Hey! <br>{{rcpt_name}}</br></HTML>"
    }

    try:
        template_client = MessageBusTemplatesClient(api_key, uri=uri)
        results = template_client.create_template(template)
    except MessageBusResponseError, error:
        print error.message
def get_templates():
    try:
        template_client = MessageBusTemplatesClient(api_key, uri=uri)
        results = template_client.get_templates()
    except MessageBusResponseError, error:
        print error.message