user_mail
- Versions
- 4.6 – 4.7
user_mail($mail,$subject, $message,$header)- 6 – 7
user_mail($key, &$message, $params)
Send an e-mail message, using Drupal variables and default settings. More information in the <a href="http://php.net/manual/en/function.mail.php">PHP function reference for mail()</a>
Parameters
$mail The mail adres or addresses where the message will be send to. The formatting of this string must comply with RFC 2822. Some examples are: user@example.com user@example.com, anotheruser@example.com User <user@example.com> User <user@example.com>, Another User <anotheruser@example.com> @param $subject Subject of the email to be sent. This must not contain any newline characters, or the mail may not be sent properly. @param $message Message to be sent. Drupal will format the correct line endings for you. @param $header String to be inserted at the end of the email header. This is typically used to add extra headers (From, Cc, and Bcc). Multiple extra headers should be separated with a CRLF (\r\n). <em>When sending mail, the mail must contain a From header.</em>
Return value
Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.
Code
modules/user.module, line 399
<?php
function user_mail($mail, $subject, $message, $header) {
if (variable_get('smtp_library', '') && file_exists(variable_get('smtp_library', ''))) {
include_once './' . variable_get('smtp_library', '');
return user_mail_wrapper($mail, $subject, $message, $header);
}
else {
/*
** Note: if you are having problems with sending mail, or mails look wrong
** when they are received you may have to modify the str_replace to suit
** your systems.
** - \r\n will work under dos and windows.
** - \n will work for linux, unix and BSDs.
** - \r will work for macs.
**
** According to RFC 2646, it's quite rude to not wrap your e-mails:
**
** "The Text/Plain media type is the lowest common denominator of
** Internet e-mail, with lines of no more than 997 characters (by
** convention usually no more than 80), and where the CRLF sequence
** represents a line break [MIME-IMT]."
**
** CRLF === \r\n
**
** http://www.rfc-editor.org/rfc/rfc2646.txt
**
*/
return mail(
$mail,
mime_header_encode($subject),
str_replace("\r", '', $message),
"MIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8; format=flowed\nContent-transfer-encoding: 8Bit\n" . $header
);
}
}
?>Login or register to post comments 