mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
bugfixes to the commit i did yesterday.
git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@3972 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
e9b13ea490
commit
ace1cf402a
3 changed files with 36 additions and 34 deletions
|
@ -87,7 +87,7 @@ class emailer
|
|||
// set up extra mail headers
|
||||
function extra_headers($headers)
|
||||
{
|
||||
$this->extra_headers .= trim($headers) . "\r\n";
|
||||
$this->extra_headers .= trim($headers) . "\n";
|
||||
}
|
||||
|
||||
function use_template($template_file, $template_lang = '')
|
||||
|
@ -178,7 +178,7 @@ class emailer
|
|||
if (preg_match('#^(Charset:(.*?))$#m', $this->msg, $match))
|
||||
{
|
||||
$this->encoding = (trim($match[2]) != '') ? trim($match[2]) : trim($lang['ENCODING']);
|
||||
$drop_header .= '[\r\n]*?' . preg_quote($match[1], '#');
|
||||
$drop_header .= '[\r\n]*?' . phpbb_preg_quote($match[1], '#');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -196,14 +196,16 @@ class emailer
|
|||
while (list($type, $address_ary) = each($this->addresses))
|
||||
{
|
||||
@reset($address_ary);
|
||||
while (list($which_ary) = each($address_ary))
|
||||
while (list(, $which_ary) = each($address_ary))
|
||||
{
|
||||
$$type .= (($$type != '') ? ',' : '') . (($which_ary['name'] != '') ? '"' . $this->encode($which_ary['name']) . '" <' . $which_ary['email'] . '>' : '<' . $which_ary['email'] . '>');
|
||||
}
|
||||
}
|
||||
|
||||
// Build header
|
||||
$this->extra_headers = (($this->replyto != '') ? "Reply-to: <$this->replyto>\r\n" : '') . (($this->from != '') ? "From: <$this->from>\r\n" : "From: <" . $board_config['board_email'] . ">\r\n") . "Return-Path: <" . $board_config['board_email'] . ">\r\nMessage-ID: <" . md5(uniqid(time())) . "@" . $board_config['server_name'] . ">\r\nMIME-Version: 1.0\r\nContent-type: text/plain; charset=" . $this->encoding . "\r\nContent-transfer-encoding: 8bit\r\nDate: " . gmdate('D, d M Y H:i:s Z', time()) . "\r\nX-Priority: 3\r\nX-MSMail-Priority: Normal\r\nX-Mailer: PHP\r\n" . (($cc != '') ? "Cc:$cc\r\n" : '') . (($bcc != '') ? "Bcc:$bcc\r\n" : '') . trim($this->extra_headers);
|
||||
$this->extra_headers = (($this->replyto != '') ? "Reply-to: <$this->replyto>\n" : '') . (($this->from != '') ? "From: <$this->from>\n" : "From: <" . $board_config['board_email'] . ">\n") . "Return-Path: <" . $board_config['board_email'] . ">\nMessage-ID: <" . md5(uniqid(time())) . "@" . $board_config['server_name'] . ">\nMIME-Version: 1.0\nContent-type: text/plain; charset=" . $this->encoding . "\nContent-transfer-encoding: 8bit\nDate: " . gmdate('D, d M Y H:i:s Z', time()) . "\nX-Priority: 3\nX-MSMail-Priority: Normal\nX-Mailer: PHP\n" . (($cc != '') ? "Cc:$cc\n" : '') . (($bcc != '') ? "Bcc:$bcc\n" : '') . trim($this->extra_headers);
|
||||
|
||||
$to = ($to == '') ? "<Undisclosed-recipients:;>" : $to;
|
||||
|
||||
// Send message ... removed $this->encode() from subject for time being
|
||||
if ( $this->use_smtp )
|
||||
|
@ -217,7 +219,7 @@ class emailer
|
|||
}
|
||||
else
|
||||
{
|
||||
$result = @mail($to, $this->subject, preg_replace("#(?<!\r)\n#s", "\r\n", $this->msg), $this->extra_headers);
|
||||
$result = @mail($to, $this->subject, preg_replace("#(?<!\r)\n#s", "\n", $this->msg), $this->extra_headers);
|
||||
}
|
||||
|
||||
// Did it work?
|
||||
|
@ -253,7 +255,7 @@ class emailer
|
|||
$str = chunk_split(base64_encode($str), $length, $spacer);
|
||||
|
||||
// remove trailing spacer and add start and end delimiters
|
||||
$str = preg_replace('#' . preg_quote($spacer) . '$#', '', $str);
|
||||
$str = preg_replace('#' . phpbb_preg_quote($spacer) . '$#', '', $str);
|
||||
|
||||
return $start . $str . $end;
|
||||
}
|
||||
|
|
|
@ -675,7 +675,7 @@ function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topi
|
|||
{
|
||||
$emailer->use_template('topic_notify', $user_lang);
|
||||
|
||||
for ($i = 0; $i < count($bcc); $i++)
|
||||
for ($i = 0; $i < count($bcc_list); $i++)
|
||||
{
|
||||
$emailer->bcc($bcc_list[$i]);
|
||||
}
|
||||
|
|
|
@ -26,21 +26,21 @@ define('SMTP_INCLUDED', 1);
|
|||
// by SirSir to allow multiline responses when
|
||||
// using SMTP Extensions
|
||||
//
|
||||
function server_parse($socket, $response)
|
||||
function server_parse($socket, $response, $line = __LINE__)
|
||||
{
|
||||
while ( substr($server_response,3,1) != ' ' )
|
||||
{
|
||||
if( !( $server_response = fgets($socket, 256) ) )
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Couldn't get mail server response codes", "", __LINE__, __FILE__);
|
||||
}
|
||||
}
|
||||
while (substr($server_response, 3, 1) != ' ')
|
||||
{
|
||||
if (!($server_response = fgets($socket, 256)))
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Couldn't get mail server response codes", "", $line, __FILE__);
|
||||
}
|
||||
}
|
||||
|
||||
if( !( substr($server_response, 0, 3) == $response ) )
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Ran into problems sending Mail. Response: $server_response", "", __LINE__, __FILE__);
|
||||
}
|
||||
}
|
||||
if (!(substr($server_response, 0, 3) == $response))
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Ran into problems sending Mail. Response: $server_response", "", $line, __FILE__);
|
||||
}
|
||||
}
|
||||
|
||||
// Replacement or substitute for PHP's mail command
|
||||
function smtpmail($mail_to, $subject, $message, $headers = '')
|
||||
|
@ -56,7 +56,7 @@ function smtpmail($mail_to, $subject, $message, $headers = '')
|
|||
{
|
||||
if (sizeof($headers) > 1)
|
||||
{
|
||||
$headers = join("\r\n", $headers);
|
||||
$headers = join("\n", $headers);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -114,34 +114,34 @@ function smtpmail($mail_to, $subject, $message, $headers = '')
|
|||
}
|
||||
|
||||
// Wait for reply
|
||||
server_parse($socket, "220");
|
||||
server_parse($socket, "220", __LINE__);
|
||||
|
||||
// Do we want to use AUTH?, send RFC2554 EHLO, else send RFC821 HELO
|
||||
// This improved as provided by SirSir to accomodate
|
||||
if( !empty($board_config['smtp_username']) && !empty($board_config['smtp_password']) )
|
||||
{
|
||||
fputs($socket, "EHLO " . $board_config['smtp_host'] . "\r\n");
|
||||
server_parse($socket, "250");
|
||||
server_parse($socket, "250", __LINE__);
|
||||
|
||||
fputs($socket, "AUTH LOGIN\r\n");
|
||||
server_parse($socket, "334");
|
||||
server_parse($socket, "334", __LINE__);
|
||||
|
||||
fputs($socket, base64_encode($board_config['smtp_username']) . "\r\n");
|
||||
server_parse($socket, "334");
|
||||
server_parse($socket, "334", __LINE__);
|
||||
|
||||
fputs($socket, base64_encode($board_config['smtp_password']) . "\r\n");
|
||||
server_parse($socket, "235");
|
||||
server_parse($socket, "235", __LINE__);
|
||||
}
|
||||
else
|
||||
{
|
||||
fputs($socket, "HELO " . $board_config['smtp_host'] . "\r\n");
|
||||
server_parse($socket, "250");
|
||||
server_parse($socket, "250", __LINE__);
|
||||
}
|
||||
|
||||
// From this point onward most server response codes should be 250
|
||||
// Specify who the mail is from....
|
||||
fputs($socket, "MAIL FROM: <" . $board_config['board_email'] . ">\r\n");
|
||||
server_parse($socket, "250");
|
||||
server_parse($socket, "250", __LINE__);
|
||||
|
||||
// Specify each user to send to and build to header.
|
||||
@reset($mail_to_array);
|
||||
|
@ -152,10 +152,11 @@ function smtpmail($mail_to, $subject, $message, $headers = '')
|
|||
if (preg_match('#[^ ]+\@[^ ]+#', $mail_to_address))
|
||||
{
|
||||
fputs($socket, "RCPT TO: $mail_to_address\r\n");
|
||||
server_parse($socket, "250");
|
||||
server_parse($socket, "250", __LINE__);
|
||||
}
|
||||
$to_header .= (($to_header !='') ? ', ' : '') . "$mail_to_address";
|
||||
}
|
||||
|
||||
// Ok now do the CC and BCC fields...
|
||||
@reset($bcc);
|
||||
while(list(, $bcc_address) = each($bcc))
|
||||
|
@ -165,7 +166,7 @@ function smtpmail($mail_to, $subject, $message, $headers = '')
|
|||
if (preg_match('#[^ ]+\@[^ ]+#', $bcc_address))
|
||||
{
|
||||
fputs($socket, "RCPT TO: $bcc_address\r\n");
|
||||
server_parse($socket, "250");
|
||||
server_parse($socket, "250", __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,7 +178,7 @@ function smtpmail($mail_to, $subject, $message, $headers = '')
|
|||
if (preg_match('#[^ ]+\@[^ ]+#', $cc_address))
|
||||
{
|
||||
fputs($socket, "RCPT TO: $cc_address\r\n");
|
||||
server_parse($socket, "250");
|
||||
server_parse($socket, "250", __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,13 +186,12 @@ function smtpmail($mail_to, $subject, $message, $headers = '')
|
|||
fputs($socket, "DATA\r\n");
|
||||
|
||||
// This is the last response code we look for until the end of the message.
|
||||
server_parse($socket, "354");
|
||||
server_parse($socket, "354", __LINE__);
|
||||
|
||||
// Send the Subject Line...
|
||||
fputs($socket, "Subject: $subject\r\n");
|
||||
|
||||
// Now the To Header.
|
||||
$to_header = ($to_header == '') ? "<Undisclosed-recipients:;>" : $to_header;
|
||||
fputs($socket, "To: $to_header\r\n");
|
||||
|
||||
// Now any custom headers....
|
||||
|
@ -202,7 +202,7 @@ function smtpmail($mail_to, $subject, $message, $headers = '')
|
|||
|
||||
// Ok the all the ingredients are mixed in let's cook this puppy...
|
||||
fputs($socket, ".\r\n");
|
||||
server_parse($socket, "250");
|
||||
server_parse($socket, "250", __LINE__);
|
||||
|
||||
// Now tell the server we are done and close the socket...
|
||||
fputs($socket, "QUIT\r\n");
|
||||
|
|
Loading…
Add table
Reference in a new issue