Last active
August 29, 2015 14:16
-
-
Save sobingt/5b9824807c6532ecf411 to your computer and use it in GitHub Desktop.
Mandrill and Templates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require '/path/to/vender/Mandrill.php'; | |
$mandrill = new Mandrill(); | |
// $mandrill = new Mandrill("YOUR_API_KEY") | |
$message = array( | |
'subject' => 'Test message', | |
'from_email' => 'you@yourdomain.com', | |
'html' => '<p>this is a test message with Mandrill\'s PHP wrapper!.</p>', | |
'to' => array(array('email' => 'recipient1@domain.com', 'name' => 'Recipient 1')), | |
'merge_vars' => array(array( | |
'rcpt' => 'recipient1@domain.com', | |
'vars' => | |
array( | |
array( | |
'name' => 'FIRSTNAME', | |
'content' => 'Recipient 1 first name'), | |
array( | |
'name' => 'LASTNAME', | |
'content' => 'Last name') | |
)))); | |
//Create a Template in mandrill.com | |
$template_name = 'Welcome Email'; | |
$template_content = array( | |
array( | |
'name' => 'main', | |
'content' => 'Hi *|FIRSTNAME|* *|LASTNAME|*, thanks for signing up.'), | |
array( | |
'name' => 'footer', | |
'content' => 'Copyright 2012.') | |
); | |
print_r($mandrill->messages->sendTemplate($template_name, $template_content, $message)); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You can add templates to your Mandrill account in the following ways: | |
-Send a template from your MailChimp account to your connected Mandrill account. | |
http://help.mandrill.com/entries/24460672-How-do-I-add-a-MailChimp-template-to-my-Mandrill-account- | |
-Custom code a template and send it to your Mandrill account via the API. | |
https://mandrillapp.com/api/docs/templates.html#method=add | |
-Go to Outbound > Templates > Code Your Own in your Mandrill account to use the Mandrill code editor to custom code your template or paste your template code. | |
Source: http://help.mandrill.com/entries/21694868-Getting-Started-with-Templates | |
'Test message',
'from_email' => 'no-reply@playnlive.co.in',
'html' => '
this is a test message with Mandrill\'s PHP wrapper!.
',
'to' => array(array('email' => 'venkatesh@playnlive.com', 'name' => 'venkatesh')),
'merge_vars' => array(array(
'rcpt' => 'venkatesh@playnlive.com',
'vars' =>
array(
array(
'name' => 'FIRSTNAME',
'content' => 'venkatesh'),
array(
'name' => 'LASTNAME',
'content' => 'sm')
))));
//Create a Template in mandrill.com
$template_name = 'Welcome Email';
$template_content = array(
array(
'name' => 'main',
'content' => 'Hi |FIRSTNAME| |LASTNAME|, thanks for signing up.'),
array(
'name' => 'footer',
'content' => 'Copyright 2012.')
);
print_r($mandrill->messages->sendTemplate($template_name, $template_content, $message));
?>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is a test message with Mandrill\'s PHP wrapper!.
', 'to' => array(array('email' => 'venkatesh@playnlive.com', 'name' => 'venkatesh')), 'merge_vars' => array(array( 'rcpt' => 'venkatesh@playnlive.com', 'vars' => array( array( 'name' => 'FIRSTNAME', 'content' => 'venkatesh'), array( 'name' => 'LASTNAME', 'content' => 'sm') )))); //Create a Template in mandrill.com $template_name = 'Welcome Email'; $template_content = array( array( 'name' => 'main', 'content' => 'Hi _|FIRSTNAME|_ _|LASTNAME|_, thanks for signing up.'), array( 'name' => 'footer', 'content' => 'Copyright 2012.') ); print_r($mandrill->messages->sendTemplate($template_name, $template_content, $message)); ?>