| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* @file
|
| 4 |
* Mime mail using Drupal API. Messaging method plug-in
|
| 5 |
*/
|
| 6 |
|
| 7 |
/**
|
| 8 |
* Implementation of hook_messaging
|
| 9 |
*/
|
| 10 |
function messaging_mime_mail_messaging($op = 'info') {
|
| 11 |
switch($op) {
|
| 12 |
case 'send methods':
|
| 13 |
$info['mail'] = array(
|
| 14 |
'name' => t('Mime Mail'), // Name for display
|
| 15 |
'destination' => 'mail', // Account property to use as destination
|
| 16 |
'send' => 'messaging_mime_mail_send', // Sending callback
|
| 17 |
'type' => MESSAGING_TYPE_PUSH, // Method type: push || pull
|
| 18 |
'glue' => "<BR>",
|
| 19 |
'footer' => "<BR><BR>", // Separator for message footer
|
| 20 |
);
|
| 21 |
return $info;
|
| 22 |
}
|
| 23 |
}
|
| 24 |
|
| 25 |
/**
|
| 26 |
* Send mime mail message to user account
|
| 27 |
*
|
| 28 |
* @param $destination
|
| 29 |
* Array of e-mails
|
| 30 |
* @param $message
|
| 31 |
* Message array
|
| 32 |
*/
|
| 33 |
function messaging_mime_mail_send($destination, $message) {
|
| 34 |
$mailkey = 'message-'.$message['type'];
|
| 35 |
$count = 0;
|
| 36 |
foreach ($destination as $to) {
|
| 37 |
$message['body'] = "<div style='padding: 20px; margin: 10px;'>" . $message['body'] . "</div>";
|
| 38 |
$count += mimemail(variable_get('site_mail', ini_get('sendmail_from')), $to, $message['subject'], $message['body'], NULL,array(),NULL,array(),$mailkey) ? 1 : 0;
|
| 39 |
}
|
| 40 |
return $count;
|
| 41 |
}
|
| 42 |
|