[Bb-trac] [bbPress] #1020: mail function needs optional 5th
paramater
bbPress
bb-trac at lists.bbpress.org
Tue Dec 30 05:00:56 GMT 2008
#1020: mail function needs optional 5th paramater
----------------------------+-----------------------------------------------
Reporter: winmutt | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: Administration | Version:
Severity: normal | Keywords:
----------------------------+-----------------------------------------------
Sendmail will often require the from envelope which is passed as a 5
parameter to mail as '-f from at domain.com'.
I modified bb_mail accordingly (static should probably be configurable for
non sendmail or windows (which uses ini settings):
if ( !function_exists( 'bb_mail' ) ) :
function bb_mail( $to, $subject, $message, $headers = '' ) {
if (!is_array($headers)) {
$headers = trim($headers);
$headers = preg_split('@\r(?:\n{0,1})|\n@', $headers, -1,
PREG_SPLIT_NO_EMPTY);
}
if (!count($headers) || !count(preg_grep('/^mime-version:\s/im',
$headers)))
$headers[] = "MIME-Version: 1.0";
if (!count(preg_grep('/^content-type:\s/im', $headers)))
$headers[] = "Content-Type: text/plain; Charset=UTF-8";
if (!count(preg_grep('/^content-transfer-encoding:\s/im',
$headers)))
$headers[] = "Content-Transfer-Encoding: 8bit";
if (!count(preg_grep('/^from:\s/im', $headers))) {
if (!$from = bb_get_option('from_email'))
if ($uri_parsed = parse_url(bb_get_option('uri')))
if ($uri_parsed['host'])
$from = 'bbpress@' .
trim(preg_replace('/^www./i', '', $uri_parsed['host']));
if ($from)
$headers[] = 'From: "' . bb_get_option('name') .
'" <' . $from . '>';
}
$headers = trim(join(defined('BB_MAIL_EOL') ? BB_MAIL_EOL : "\n",
$headers));
return @mail($to, $subject, $message, $headers, '-f '.$from);
}
endif;
--
Ticket URL: <http://trac.bbpress.org/ticket/1020>
bbPress <http://bbpress.org/>
Innovative forum development
More information about the Bb-trac
mailing list