Skip to content

Instantly share code, notes, and snippets.

@sergiohidalgo
Last active October 11, 2016 21:27
Show Gist options
  • Save sergiohidalgo/bedde2765c6211e5e293657f866ceab7 to your computer and use it in GitHub Desktop.
Save sergiohidalgo/bedde2765c6211e5e293657f866ceab7 to your computer and use it in GitHub Desktop.
Enviar datos por mandrill con Plantilla o un texto HTML
<?
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