Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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

  1. Have the templates I created on Mailchimp, be visible on my own server.
  2. 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);
  }
share|improve this question

1 Answer 1

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

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.

share|improve this answer
    
Yes i tested some of the functionality already with mandrill as say, successful.The idea was to see the templates on my own server.Edit them as required in there, save them....and start using them.i updated the question with a sample code i use. –  HenryW May 13 at 19:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.