Created
August 8, 2016 23:49
-
-
Save psorensen/e068a4eb31fe293f59f9df53aa365ab1 to your computer and use it in GitHub Desktop.
wpMandrill example send function
This file contains 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
function SendTemplate() { | |
// Create a template called MyCoolTemplate and use this code: | |
$template_code = ' | |
Hello *|FNAME|*, | |
<p>Your personal coupon code is: *|COUPON|*</p> | |
<p>Event Date: *|DATE|*</p> | |
<p>Address: *|ADDRESS|*</p> | |
<div mc:edit="body"></div> | |
<div mc:edit="sidebar"></div> | |
'; | |
// Sending an email using a template and merge vars | |
$to = 'one@email.com'; | |
$globalmv = array( | |
array('name' => 'date', 'content' => 'Tomorrow morning!'), | |
array('name' => 'address', 'content' => 'Our office') | |
); | |
$mv = array( | |
array( | |
'rcpt' => 'one@email.com', | |
'vars' => array( | |
array('name' => 'fname', 'content' => 'Number One'), | |
array('name' => 'coupon', 'content' => '123456'), | |
) | |
), | |
array( | |
'rcpt' => 'two@email.com', | |
'vars' => array( | |
array('name' => 'fname', 'content' => 'Number Two'), | |
array('name' => 'coupon', 'content' => '654321'), | |
) | |
), | |
); | |
$message = array( | |
'subject' => 'Email Subject', | |
'from_name' => 'Freedie', | |
'from_email' => 'your@email.com', | |
'to' => $to, | |
'merge' => true, | |
'global_merge_vars' => $globalmv, | |
'merge_vars' => $mv, | |
'html' => array( | |
array('name' => 'body', 'content' => 'This is the body!'), | |
array('name' => 'sidebar', 'content' => 'This is the sidebar!'), | |
) | |
); | |
wpMandrill::sendEmail( | |
$message, | |
$tags = array('Tag 1', 'Tag 2'), | |
$template_name = 'MyCoolTemplate' | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment