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);
}