Last active
October 11, 2016 21:27
-
-
Save sergiohidalgo/bedde2765c6211e5e293657f866ceab7 to your computer and use it in GitHub Desktop.
Enviar datos por mandrill con Plantilla o un texto HTML
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
<? | |
require 'vendor/autoload.php'; | |
$mandrill = new Mandrill(API_KEY_MANDRILL); | |
$message = [ | |
'from_email' => 'info@digitalmeat.cl', | |
'from_name' => 'Digital Meat', | |
'subject' => 'My Subject Subject', | |
'preserve_recipients' => FALSE, | |
'to' => [ | |
[ | |
'email' => 'shidalgo@digitalmeat.cl', | |
'name' => 'sergio', | |
'type' => 'to' | |
] | |
] | |
]; | |
# Message HTML: | |
//$message['html'] = 'my text'; | |
//$mandrill->messages->send($message); | |
# Message Template: (in HTML template: *|NAME|* *|LASTNAME|*) | |
$vars_for_template = [ | |
'name' => 'Sergio', | |
'lastname' => 'Hidalgo' | |
]; | |
foreach($vars_for_template as $key => $value): | |
// No modificar variables ! | |
$message["global_merge_vars"][] = [ | |
'name' => $key, | |
'content' => $value | |
]; | |
endforeach; | |
$mandrill->messages->sendTemplate('template-test', [] ,$message); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment