Skip to content

Instantly share code, notes, and snippets.

@fotoflo
Created November 24, 2016 02:14
Show Gist options
  • Save fotoflo/b1434b51a38a38647a345dbafd624443 to your computer and use it in GitHub Desktop.
Save fotoflo/b1434b51a38a38647a345dbafd624443 to your computer and use it in GitHub Desktop.
Create a centered List of images in a table for MailChimp Emails
<div class="mcnTextContent">
<table border="0" cellpadding="20" cellspacing="0" width="600" id="emailContainer">
<tr>
<td align="center" valign="top">
{{#if images}}
{{#each images}}
<img style="max-width: 360px; margin: 0 auto;" src="{{this}}"/>
<br/>
{{/each}}
{{/if}}
<br/>
</td>
</tr>
</table>
</div>
@fotoflo
Copy link
Author

fotoflo commented Nov 24, 2016

This corresponds to the following data structure to be sent to Mandrill:

{
    "key": "YOUR_API_KEY",
    "template_name": "YOUR_TEMPLATE_NAME",
    "template_content": [],
    "message": {
      "subject": "YOUR EMAIL SUBJECT!",
      "from_name": "from name",
        "from_email": "support@your_company.com",
        "to": [
            {
                "email": "recipient@gmail.com",
                "name": "recipiant name",
                "type": "to"
            }
        ],
        "merge": true,
        "merge_language": "handlebars",
        "global_merge_vars": [
            {
              "name": "IMAGES",
               "content":  [ "http://i.imgur.com/iJWRYPSb.jpg", "http://i.imgur.com/ZZoR2BHb.jpg", "http://i.imgur.com/ZStdDkvb.jpg"]
          }
        ]
    },
    "async": false,
    "ip_pool": "Main Pool"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment