Line 160 | Line 160 |
---|
function headers($headers) { $this->extra_headers[] = trim($headers);
|
function headers($headers) { $this->extra_headers[] = trim($headers);
|
| }
/** * Adds X-AntiAbuse headers * * @param array $config Configuration array * @param user $user A user object * * @return null */ function anti_abuse_headers($config, $user) { $this->headers('X-AntiAbuse: Board servername - ' . mail_encode($config['server_name'])); $this->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']); $this->headers('X-AntiAbuse: Username - ' . mail_encode($user->data['username'])); $this->headers('X-AntiAbuse: User IP - ' . $user->ip);
|
}
/**
| }
/**
|
Line 371 | Line 387 |
---|
$this->queue->save(); return; }
|
$this->queue->save(); return; }
|
| }
/** * Generates a valid message id to be used in emails * * @return string message id */ function generate_message_id() { global $config;
$domain = 'phpbb.generated'; if ($config['server_name']) { $domain = $config['server_name']; } else if (!empty($_SERVER['SERVER_NAME'])) { $domain = $_SERVER['SERVER_NAME']; }
return md5(unique_id(time())) . '@' . $domain;
|
}
/**
| }
/**
|
Line 399 | Line 437 |
---|
$headers[] = 'Return-Path: <' . $config['board_email'] . '>'; $headers[] = 'Sender: <' . $config['board_email'] . '>'; $headers[] = 'MIME-Version: 1.0';
|
$headers[] = 'Return-Path: <' . $config['board_email'] . '>'; $headers[] = 'Sender: <' . $config['board_email'] . '>'; $headers[] = 'MIME-Version: 1.0';
|
$headers[] = 'Message-ID: <' . md5(unique_id(time())) . '@' . $config['server_name'] . '>';
| $headers[] = 'Message-ID: <' . $this->generate_message_id() . '>';
|
$headers[] = 'Date: ' . date('r', time()); $headers[] = 'Content-Type: text/plain; charset=UTF-8'; // format=flowed $headers[] = 'Content-Transfer-Encoding: 8bit'; // 7bit
| $headers[] = 'Date: ' . date('r', time()); $headers[] = 'Content-Type: text/plain; charset=UTF-8'; // format=flowed $headers[] = 'Content-Transfer-Encoding: 8bit'; // 7bit
|
Line 552 | Line 590 |
---|
if (!$use_queue) { include_once($phpbb_root_path . 'includes/functions_jabber.' . $phpEx);
|
if (!$use_queue) { include_once($phpbb_root_path . 'includes/functions_jabber.' . $phpEx);
|
$this->jabber = new jabber($config['jab_host'], $config['jab_port'], $config['jab_username'], $config['jab_password'], $config['jab_use_ssl']);
| $this->jabber = new jabber($config['jab_host'], $config['jab_port'], $config['jab_username'], htmlspecialchars_decode($config['jab_password']), $config['jab_use_ssl']);
|
if (!$this->jabber->connect()) {
| if (!$this->jabber->connect()) {
|
Line 699 | Line 737 |
---|
$lock_fp = $this->lock();
|
$lock_fp = $this->lock();
|
| // avoid races, check file existence once $have_cache_file = file_exists($this->cache_file); if (!$have_cache_file || $config['last_queue_run'] > time() - $config['queue_interval']) { if (!$have_cache_file) {
|
set_config('last_queue_run', time(), true);
|
set_config('last_queue_run', time(), true);
|
| }
|
|
|
if (!file_exists($this->cache_file) || filemtime($this->cache_file) > time() - $config['queue_interval']) {
| |
$this->unlock($lock_fp); return; }
|
$this->unlock($lock_fp); return; }
|
| set_config('last_queue_run', time(), true);
|
include($this->cache_file);
| include($this->cache_file);
|
Line 753 | Line 798 |
---|
}
include_once($phpbb_root_path . 'includes/functions_jabber.' . $phpEx);
|
}
include_once($phpbb_root_path . 'includes/functions_jabber.' . $phpEx);
|
$this->jabber = new jabber($config['jab_host'], $config['jab_port'], $config['jab_username'], $config['jab_password'], $config['jab_use_ssl']);
| $this->jabber = new jabber($config['jab_host'], $config['jab_port'], $config['jab_username'], htmlspecialchars_decode($config['jab_password']), $config['jab_use_ssl']);
|
if (!$this->jabber->connect()) {
| if (!$this->jabber->connect()) {
|
Line 975 | Line 1020 |
---|
$smtp->add_backtrace('Connecting to ' . $config['smtp_host'] . ':' . $config['smtp_port']);
// Ok we have error checked as much as we can to this point let's get on it already.
|
$smtp->add_backtrace('Connecting to ' . $config['smtp_host'] . ':' . $config['smtp_port']);
// Ok we have error checked as much as we can to this point let's get on it already.
|
ob_start();
| if (!class_exists('phpbb_error_collector')) { global $phpbb_root_path, $phpEx; include($phpbb_root_path . 'includes/error_collector.' . $phpEx); } $collector = new phpbb_error_collector; $collector->install();
|
$smtp->socket = fsockopen($config['smtp_host'], $config['smtp_port'], $errno, $errstr, 20);
|
$smtp->socket = fsockopen($config['smtp_host'], $config['smtp_port'], $errno, $errstr, 20);
|
$error_contents = ob_get_clean();
| $collector->uninstall(); $error_contents = $collector->format_errors();
|
if (!$smtp->socket) {
| if (!$smtp->socket) {
|
Line 999 | Line 1051 |
---|
}
// Let me in. This function handles the complete authentication process
|
}
// Let me in. This function handles the complete authentication process
|
if ($err_msg = $smtp->log_into_server($config['smtp_host'], $config['smtp_username'], $config['smtp_password'], $config['smtp_auth_method']))
| if ($err_msg = $smtp->log_into_server($config['smtp_host'], $config['smtp_username'], htmlspecialchars_decode($config['smtp_password']), $config['smtp_auth_method']))
|
{ $smtp->close_session($err_msg); return false;
| { $smtp->close_session($err_msg); return false;
|
Line 1608 | Line 1660 |
---|
*/ function phpbb_mail($to, $subject, $msg, $headers, $eol, &$err_msg) {
|
*/ function phpbb_mail($to, $subject, $msg, $headers, $eol, &$err_msg) {
|
global $config;
| global $config, $phpbb_root_path, $phpEx;
|
// We use the EOL character for the OS here because the PHP mail function does not correctly transform line endings. On Windows SMTP is used (SMTP is \r\n), on UNIX a command is used... // Reference: http://bugs.php.net/bug.php?id=15841 $headers = implode($eol, $headers);
|
// We use the EOL character for the OS here because the PHP mail function does not correctly transform line endings. On Windows SMTP is used (SMTP is \r\n), on UNIX a command is used... // Reference: http://bugs.php.net/bug.php?id=15841 $headers = implode($eol, $headers);
|
ob_start();
| if (!class_exists('phpbb_error_collector')) { include($phpbb_root_path . 'includes/error_collector.' . $phpEx); }
$collector = new phpbb_error_collector; $collector->install();
|
// On some PHP Versions mail() *may* fail if there are newlines within the subject. // Newlines are used as a delimiter for lines in mail_encode() according to RFC 2045 section 6.8. // Because PHP can't decide what is wanted we revert back to the non-RFC-compliant way of separating by one space (Use '' as parameter to mail_encode() results in SPACE used) $result = $config['email_function_name']($to, mail_encode($subject, ''), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers);
|
// On some PHP Versions mail() *may* fail if there are newlines within the subject. // Newlines are used as a delimiter for lines in mail_encode() according to RFC 2045 section 6.8. // Because PHP can't decide what is wanted we revert back to the non-RFC-compliant way of separating by one space (Use '' as parameter to mail_encode() results in SPACE used) $result = $config['email_function_name']($to, mail_encode($subject, ''), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers);
|
$err_msg = ob_get_clean();
| $collector->uninstall(); $err_msg = $collector->format_errors();
|
return $result; }
| return $result; }
|