Created
June 20, 2014 14:13
-
-
Save thomasdegry/8d7bf418d863d381bf47 to your computer and use it in GitHub Desktop.
Mandrill
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 | |
$message_klant = '<html><body>'; | |
$message_klant .= '<h2>Beste ' . $voornaam . '</h2>'; | |
$message_klant .= '<p>Fijn dat u zonet op ' . date('d-m H:i') . ', ' . $aantal . 'x "' . $product_naam . '" bestelde op mijn website.</p>'; | |
$message_klant .= '<p>Van zodra u uw bestelling betaalt verstuur ik deze met de post!</p>'; | |
if($product_naam == 'Ticket Herbert in concert') { | |
$message_klant .= '<p>HERBERT IN CONCERT'; | |
} else { | |
$message_klant .= '<p> Herbert Verhaeghe'; | |
} | |
$message_klant .= '<br/> Boomgaardstraat 135'; | |
$message_klant .= '<br/> 8520 Kuurne'; | |
if($product_naam == 'Ticket Herbert in concert') { | |
$message_klant .= '<br/> Rekeningnummer: BE83 6528 2490 0715'; | |
$message_klant .= '<br/> Mededeling: Bestelling tickets van ' . $voornaam . ' ' . $naam . ' op ' . date('d-m H:i'); | |
$message_klant .= '<br/> Bedrag: ' . $totaal . ' (' . $subtotaal . ' euro voor de tickets en ' . $shipping . ' euro verzending)</p>'; | |
} else { | |
$message_klant .= '<br/> Rekeningnummer: BE75 3770 3765 6851'; | |
$message_klant .= '<br/> Mededeling: Bestelling van ' . $voornaam . ' ' . $naam . ' op ' . date('d-m H:i'); | |
$message_klant .= '<br/> Bedrag: ' . $totaal . ' (' . $subtotaal . ' euro voor de producten en ' . $shipping . ' euro verzending)</p>'; | |
} | |
$message_klant .= '<p>Groetjes, <br/>Herbert.</p>'; | |
$message_klant .= '<p><small>Indien er vragen of problemen zijn kunt u mailen naar <a href="mailto:[email protected]">[email protected]</a></small></p>'; | |
$message_klant .= '</body></html>'; | |
try { | |
$mandrill_client = new Mandrill('API_KEY'); | |
$message = array( | |
'html' => $message_klant, | |
'text' => strip_tags($message_klant), | |
'subject' => 'Bedankt voor uw bestelling op onze webshop', | |
'from_email' => '[email protected]', | |
'from_name' => 'Webshop herbertverhaeghe.be', | |
'to' => array( | |
array( | |
'email' => $email, | |
'name' => $voornaam . ' ' . $naam, | |
'type' => 'to' | |
) | |
), | |
'headers' => array('Reply-To' => '[email protected]'), | |
'important' => false, | |
'track_opens' => null, | |
'track_clicks' => null, | |
'auto_text' => null, | |
'auto_html' => null, | |
'inline_css' => null, | |
'url_strip_qs' => null, | |
'preserve_recipients' => null, | |
'view_content_link' => null, | |
'bcc_address' => '[email protected]', | |
'tracking_domain' => null, | |
'signing_domain' => null, | |
'return_path_domain' => null, | |
'merge' => true, | |
'global_merge_vars' => null, | |
'merge_vars' => null, | |
'tags' => array('bestelling', 'webshop', 'herbertverhaeghe'), | |
'subaccount' => null, | |
'google_analytics_domains' => null, | |
'google_analytics_campaign' => null, | |
'metadata' => array('website' => 'www.herbertverhaeghe.be'), | |
'recipient_metadata' => null, | |
'attachments' => null, | |
'images' => null | |
); | |
$async = true; | |
$result = $mandrill_client->messages->send($message, $async); | |
} catch(Mandrill_Error $e) { | |
// Mandrill errors are thrown as exceptions | |
echo 'A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage(); | |
// A mandrill error occurred: Mandrill_Unknown_Subaccount - No subaccount exists with the id 'customer-123' | |
throw $e; | |
die(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment