Простая функция для отправки почты drupal
09.08.2015
Просто добавляем в своем модуле или template.php
<?php
function send_mail($to, $subject, $message) {
$my_module = 'custom';
$my_mail_token = microtime();
$from = variable_get('system_mail', 'My Email Address <example@example.com>');
$message = array(
'id' => $my_module . '_' . $my_mail_token,
'to' => $to,
'subject' => $subject,
'body' => array($message),
'headers' => array(
'From' => $from,
'Sender' => $from,
'Return-Path' => $from,
),
);
$system = drupal_mail_system($my_module, $my_mail_token);
$message = $system->format($message);
if ($system->mail($message)) {
return TRUE;
}
else {
return FALSE;
}
}
#Drupal
