function fp_mail
Search API
7.x misc.inc | fp_mail($to, $subject, $msg, $bool_html = FALSE, $attachments = array(), $bool_string_attachment = FALSE) |
6.x misc.inc | fp_mail($to, $subject, $msg, |
5.x misc.inc | fp_mail($to, $subject, $msg) |
Send an email. Drop-in replacement for PHP's mail() command, but can use SMTP protocol if enabled.
For attachments (only for use in SMTP), the array can be one of two methods:
(1) $arr["full_filename"] => "filename" or (2) $arr['filename'] = "string that makes up attachment"
For method #2, $bool_string_attachment must be set to TRUE.
5 calls to fp_mail()
- DatabaseHandler::db_error in classes/
DatabaseHandler.php - Draw out the error onto the screen.
- lassie_check in modules/
lassie/ lassie.module - Check to see if an email needs to be sent regarding this job.
- notify_by_mail in modules/
notify/ notify.module - system_popup_report_contact_form_submit in modules/
system/ system.module - _fp_error_handler in includes/
misc.inc - This is our custom error handler, which will intercept PHP warnings, notices, etc, and let us display them, log them, etc.
File
- includes/
misc.inc, line 609 - This file contains misc functions for FlightPath
Code
function fp_mail($to, $subject, $msg, $bool_html = FALSE, $attachments = array(), $bool_string_attachment = FALSE) {
// TODO: In the future, check to see if there are any other modules which invoke a hook to intercept mail.
// The reason we do this md5 check is so that we don't try to send identical emails over and over. This can happen if we are trying
// to email regarding the mysql server being down, and when we try to do a "watchdog", which has to use the mysql server,
// we try to send ANOTHER error, then we are right back here and try to send ANOTHER email, etc, etc.
$md5_check = md5($to . $subject . $msg . time());
if (isset($_SESSION ['fp_mail_last_sent_md5'])) {
if ($_SESSION ['fp_mail_last_sent_md5'] == $md5_check) {
return;
}
}
$_SESSION ['fp_mail_last_sent_md5'] = $md5_check;
watchdog('fp_mail', t("Sending mail to @to, subject: @subject. Last sent md5: @md5", array("@to" => $to, "@subject" => $subject, "@md5" => $md5_check)), array(), WATCHDOG_DEBUG);
if (module_enabled('smtp')) {
smtp_mail($to, $subject, $msg, $bool_html, $attachments, $bool_string_attachment);
return;
}
else {
$headers = array();
if ($bool_html) {
// To send HTML mail, the Content-type header must be set
$headers [] = 'MIME-Version: 1.0';
$headers [] = 'Content-type: text/html; charset=iso-8859-1';
}
mail($to, $subject, $msg, implode("\r\n", $headers));
}
}