Details
Description
Adding a hook which is called after getting the content of the mail and before tokenizing it.
Doing this we can alter the content and subject of the mail before it is tokenized and send to the recipients.
See file attached. I placed the htmlToText() function after the hook implementation because the alter functions should have the original value, I think.
Why? With this hook we can
- use the mailchimp api to generate inline css calls (http://apidocs.mailchimp.com/api/2.0/helper/inline-css.php),
- use the mailchimp api to generate the text template (http://apidocs.mailchimp.com/api/2.0/helper/generate-text.php),
- ...
Example implemenation:
---------------------------------
$data = array(
'apikey' => '<something>',
'html' => $templates['html'],
);
$options = array(
'method' => 'POST',
'data' => drupal_http_build_query($data),
'headers' => array(
'Content-Type' => 'application/x-www-form-urlencoded',
),
);
$response = drupal_http_request('https://us2.api.mailchimp.com/2.0/helper/inline-css.json', $options);
//@todo: check if response is ok
$result = drupal_json_decode($response->data);
$templates['html'] = $result['html'];