Mobile app version of vmapp.org
Login or Join
Kaufman445

: Can Mailchimp APIs be used to send templated transaction email triggered by actions on my website? I am currently playing around with Mailchimp's APIs, but the documentation to me is not very

@Kaufman445

Posted in: #Email #Mailchimp

I am currently playing around with Mailchimp's APIs, but the documentation to me is not very clear. Here is what I actually want:


Have the templates I created on Mailchimp, be visible on my own server.
Assign each template I made to a specific action (logged in,subscribed, created order, or new password). This is functionality that I already tested with Mandrill, but the template exists on mandrill's account.


If option 1 is not possible, can I still make my own template in my own environment, and send that template out over Mailchimp or Mandrill?

Should I use Mailchimps services for this or send the email directly from my own server?

Curent used function:

function tep_mandrill_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address) {

if (SEND_EMAILS != 'true') return false;
$uri = 'https://mandrillapp.com/api/1.0/messages/send-template.json';

$postString = '{
"key": "xxxxxxxxxxx",
"template_name": "sometemplatename",
"template_content": [
{
"name": "header",
"content": "*|HEADERSTUFF|*"
},
{
"name": "main",
"content": "*|CONTENTSTUFF|*"
},
{
"name": "footer",
"content": "*|FOOTERSTUFF|*"
}
],
"message": {
"subject": "'.$email_subject.'",
"from_email": "'.$from_email_adress.'",
"from_name": "'.$from_email_name.'",
"to": [
{
"email": "'.$to_email_address.'",
"name": "'.$to_name.'"
}
],
"important": false,
"track_opens": true,
"merge": true,

"merge_vars": [
{
"rcpt": "'.$to_email_address.'",
"vars": [
{
"name": "HEADERSTUFF",
"content": "'.$email_subject.'"
},
{
"name": "CONTENTSTUFF",
"content": "'.$email_text.'"
},
{
"name": "FOOTERSTUFF",
"content": "paulvale-foot"
}
]
}
],
"tags": [
"password_forgotten"
]
},
"async": false,
"ip_pool": "Main Pool"
}';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $uri);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
curl_exec($ch);
}

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Kaufman445

1 Comments

Sorted by latest first Latest Oldest Best

 

@Heady270

The types of emails that you are talking about are "transactional" emails not "newsletter" emails. The main Mailchimp product is meant for sending out newsletters, where you send out nearly identical emails to everybody on a mailing list, all at the same time. Transactional emails are sent as people need them and are triggered by actions on your site.

The main Mailchimp offering is geared towards sending out newsletters. Their Mandrill division is set up to handle transactional emails. If you are using Mailchimp for this, you certainly want to be using Mandrill.

When using a mail service that works with templates, you would typically not need the template to be visible on your server. You would set up templates like:

Hello $user,

Your new password is: $password


You would use the API to pass the data needed to send the email to the service:

mandrill->send(
"to" -> "user@example.com",
"template" -> "new password",
"user" -> "Bob",
"password" -> "GXFjTZNy"
);


I'm not specifically familiar with Mandrill, so their API calls and template syntax are likely to look somewhat different than what I have posted here. They do have documentation for


Template syntax
Sending a template message


It looks to me that the Mandrill API is a reasonable choice for transactional email from your website.

If you don't want to specify your templates ahead of time, you could have your application add its own templates. There is also a way to list all the available templates. If nothing else, you could send your emails without using templates at all.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme