changed email class to the approach paul did with the class in 2.2 (the delimiter used as a 'fix' has not really solved the initial problem). fixed timezone display.

git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@3966 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2003-05-03 23:24:04 +00:00
parent 17a3c09d93
commit c0d96c080d
18 changed files with 291 additions and 262 deletions

View file

@ -79,10 +79,10 @@ if ( isset($HTTP_POST_VARS['submit']) )
if ( $row = $db->sql_fetchrow($result) )
{
$bcc_list = '';
$bcc_list = array();
do
{
$bcc_list .= ( ( $bcc_list != '' ) ? ', ' : '' ) . $row['user_email'];
$bcc_list[] = $row['user_email'];
}
while ( $row = $db->sql_fetchrow($result) );
@ -116,12 +116,18 @@ if ( isset($HTTP_POST_VARS['submit']) )
$emailer = new emailer($board_config['smtp_delivery']);
$email_headers = 'Return-Path: ' . $board_config['board_email'] . "\nFrom: " . $board_config['board_email'] . "\n";
$email_headers .= 'X-AntiAbuse: Board servername - ' . $board_config['server_name'] . "\n";
$emailer->from($board_config['board_email']);
$emailer->replyto($board_config['board_email']);
for ($i = 0; $i < count($bcc_list); $i++)
{
$emailer->bcc($bcc_list[$i]);
}
$email_headers = 'X-AntiAbuse: Board servername - ' . $board_config['server_name'] . "\n";
$email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "\n";
$email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "\n";
$email_headers .= 'X-AntiAbuse: User IP - ' . decode_ip($user_ip) . "\n";
$email_headers .= "Bcc: $bcc_list\n";
$emailer->use_template('admin_send_email');
$emailer->email_address($board_config['board_email']);

View file

@ -64,6 +64,10 @@ $template->set_filenames(array(
'header' => 'admin/page_header.tpl')
);
// Format Timezone. We are unable to use array_pop here, because of PHP3 compatibility
$l_timezone = explode('.', $board_config['board_timezone']);
$l_timezone = ($l_timezone[count($l_timezone)-1] != 0) ? $lang[sprintf('%.1f', $board_config['board_timezone'])] : $lang[number_format($board_config['board_timezone'])];
//
// The following assigns all _common_ variables that may be used at any point
// in a template. Note that all URL's should be wrapped in append_sid, as
@ -79,7 +83,7 @@ $template->assign_vars(array(
'U_INDEX' => append_sid('../index.'.$phpEx),
'S_TIMEZONE' => sprintf($lang['All_times'], $lang[$board_config['board_timezone']]),
'S_TIMEZONE' => sprintf($lang['All_times'], $l_timezone),
'S_LOGIN_ACTION' => append_sid('../login.'.$phpEx),
'S_JUMPBOX_ACTION' => append_sid('../viewforum.'.$phpEx),
'S_CURRENT_TIME' => sprintf($lang['Current_time'], create_date($board_config['default_dateformat'], time(), $board_config['board_timezone'])),

View file

@ -109,6 +109,7 @@ p,ul,td {font-size:10pt;}
<li>Fixed wrong language var in install.php - FTP Config screen</li>
<li>Fixed alt tag for locked topic images in viewforum_body.tpl</li>
<li>Fixed typo in groupcp.php - $lang['Unsub_success'] instead of $lang['Usub_success']</li>
<li>Fixed timezone display</li>
</ul>
<a name="203"></a><h3 class="h3">1.ii. Changes since 2.0.3</h3>

View file

@ -274,12 +274,12 @@ else if ( isset($HTTP_POST_VARS['joingroup']) && $group_id )
include($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']);
$email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\n";
$emailer->from($board_config['board_email']);
$emailer->replyto($board_config['board_email']);
$emailer->use_template('group_request', $moderator['user_lang']);
$emailer->email_address($moderator['user_email']);
$emailer->set_subject($lang['Group_request']);
$emailer->extra_headers($email_headers);
$emailer->assign_vars(array(
'SITENAME' => $board_config['sitename'],
@ -552,12 +552,12 @@ else if ( $group_id )
include($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']);
$email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\n";
$emailer->from($board_config['board_email']);
$emailer->replyto($board_config['board_email']);
$emailer->use_template('group_added', $row['user_lang']);
$emailer->email_address($row['user_email']);
$emailer->set_subject($lang['Group_added']);
$emailer->extra_headers($email_headers);
$emailer->assign_vars(array(
'SITENAME' => $board_config['sitename'],
@ -684,10 +684,10 @@ else if ( $group_id )
message_die(GENERAL_ERROR, 'Could not get user email information', '', __LINE__, __FILE__, $sql);
}
$email_addresses = '';
while( $row = $db->sql_fetchrow($result) )
$bcc_list = array();
while ($row = $db->sql_fetchrow($result))
{
$email_addresses .= ( ( $email_addresses != '' ) ? ', ' : '' ) . $row['user_email'];
$bcc_list[] = $row['user_email'];
}
//
@ -707,12 +707,17 @@ else if ( $group_id )
include($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']);
$email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\nBcc: " . $email_addresses . "\n";
$emailer->from($board_config['board_email']);
$emailer->replyto($board_config['board_email']);
for ($i = 0; $i < count($bcc_list); $i++)
{
$emailer->bcc($bcc_list[$i]);
}
$emailer->use_template('group_approved');
$emailer->email_address($lang['Group_approved'] . ':;');//$userdata['user_email']
$emailer->set_subject($lang['Group_approved']);
$emailer->extra_headers($email_headers);
$emailer->assign_vars(array(
'SITENAME' => $board_config['sitename'],

View file

@ -26,159 +26,144 @@
//
class emailer
{
var $tpl_file;
var $msg, $subject, $extra_headers;
var $to_addres, $cc_address, $bcc_address;
var $reply_to, $from;
var $use_smtp;
var $msg;
var $mimeOut;
var $arrPlaceHolders = array(); // an associative array that has the key = placeHolderName and val = placeHolderValue.
var $subject, $extra_headers, $address;
var $tpl_msg = array();
function emailer($use_smtp)
{
$this->reset();
$this->use_smtp = $use_smtp;
$this->tpl_file = NULL;
$this->address = NULL;
$this->msg = '';
$this->mimeOut = '';
}
//
// Resets all the data (address, template file, etc etc to default
//
function reset()
{
$this->tpl_file = '';
$this->address = '';
$this->msg = '';
$this->memOut = '';
$this->vars = '';
$this->addresses = array();
$this->vars = $this->msg = $this->extra_headers = $this->replyto = $this->from = '';
}
//
// Sets an email address to send to
//
function email_address($address, $lang_var = '', $template_lang = '')
function email_address($address, $realname = '')
{
global $board_config, $phpbb_root_path, $phpEx;
$this->address = '';
// If a language variable for non-disclosure is passed, we prepend it to the address.
if ($lang_var != '')
{
if ( $template_lang == '' )
{
$template_lang = $board_config['default_lang'];
}
$language_file = @phpbb_realpath($phpbb_root_path . 'language/lang_' . $template_lang . '/lang_main.' . $phpEx);
if ( !@file_exists(@phpbb_realpath($language_file)) )
{
$language_file = @phpbb_realpath($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx);
}
if ( @file_exists(@phpbb_realpath($language_file)) )
{
include($language_file);
$this->address .= $lang[$lang_var];
}
}
$this->address .= $address;
$pos = sizeof($this->addresses['to']);
$this->addresses['to'][$pos]['email'] = trim($address);
$this->addresses['to'][$pos]['name'] = trim($realname);
}
function cc($address, $realname = '')
{
$pos = sizeof($this->addresses['cc']);
$this->addresses['cc'][$pos]['email'] = trim($address);
$this->addresses['cc'][$pos]['name'] = trim($realname);
}
function bcc($address, $realname = '')
{
$pos = sizeof($this->addresses['bcc']);
$this->addresses['bcc'][$pos]['email'] = trim($address);
$this->addresses['bcc'][$pos]['name'] = trim($realname);
}
function replyto($address)
{
$this->replyto = trim($address);
}
function from($address)
{
$this->from = trim($address);
}
//
// set up subject for mail
//
function set_subject($subject = '')
{
$this->subject = trim(preg_replace('#[\n\r]+#s', '', $subject));
$this->subject = trim($subject);
}
//
// set up extra mail headers
//
function extra_headers($headers)
{
$this->extra_headers = $headers;
$this->extra_headers .= trim($headers) . "\r\n";
}
function use_template($template_file, $template_lang = '')
{
global $board_config, $phpbb_root_path;
if ( $template_lang == '' )
{
$template_lang = $board_config['default_lang'];
}
$this->tpl_file = @phpbb_realpath($phpbb_root_path . 'language/lang_' . $template_lang . '/email/' . $template_file . '.tpl');
if ( !file_exists(phpbb_realpath($this->tpl_file)) )
{
$this->tpl_file = @phpbb_realpath($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/email/' . $template_file . '.tpl');
if ( !file_exists(phpbb_realpath($this->tpl_file)) )
{
message_die(GENERAL_ERROR, 'Could not find email template file ' . $template_file, '', __LINE__, __FILE__);
}
}
if ( !$this->load_msg() )
{
message_die(GENERAL_ERROR, 'Could not load email template file ' . $template_file, '', __LINE__, __FILE__);
}
return true;
}
//
// Open the template file and read in the message
//
function load_msg()
{
if ( $this->tpl_file == NULL )
if (trim($template_file) == '')
{
message_die(GENERAL_ERROR, 'No template file set', '', __LINE__, __FILE__);
}
if ( !($fd = fopen($this->tpl_file, 'r')) )
if (trim($template_lang) == '')
{
message_die(GENERAL_ERROR, 'Failed opening template file', '', __LINE__, __FILE__);
$template_lang = $board_config['default_lang'];
}
$this->msg .= fread($fd, filesize($this->tpl_file));
fclose($fd);
if (empty($this->tpl_msg[$template_lang . $template_file]))
{
$tpl_file = $phpbb_root_path . 'language/lang_' . $template_lang . '/email/' . $template_file . '.tpl';
if (!@file_exists(@phpbb_realpath($tpl_file)))
{
$tpl_file = $phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/email/' . $template_file . '.tpl';
if (!@file_exists(@phpbb_realpath($tpl_file)))
{
message_die(GENERAL_ERROR, 'Could not find email template file :: ' . $template_file, '', __LINE__, __FILE__);
}
}
if (!($fd = @fopen($tpl_file, 'r')))
{
message_die(GENERAL_ERROR, 'Failed opening template file :: ' . $tpl_file, '', __LINE__, __FILE__);
}
$this->tpl_msg[$template_lang . $template_file] = fread($fd, filesize($tpl_file));
fclose($fd);
}
$this->msg = $this->tpl_msg[$template_lang . $template_file];
return true;
}
// assign variables
function assign_vars($vars)
{
$this->vars = ( empty($this->vars) ) ? $vars : $this->vars . $vars;
$this->vars = (empty($this->vars)) ? $vars : $this->vars . $vars;
}
function parse_email()
// Send the mail out to the recipients set previously in var $this->address
function send()
{
global $lang;
@reset($this->vars);
while (list($key, $val) = @each($this->vars))
{
$$key = $val;
}
global $board_config, $lang, $phpEx, $phpbb_root_path;
// Escape all quotes, else the eval will fail.
$this->msg = str_replace ("'", "\'", $this->msg);
$this->msg = preg_replace('#\{([a-z0-9\-_]*?)\}#is', "' . $\\1 . '", $this->msg);
// Set vars
foreach ($this->vars as $key => $val)
{
$$key = $val;
}
eval("\$this->msg = '$this->msg';");
//
// Clear vars
foreach ($this->vars as $key => $val)
{
unset($$key);
}
// We now try and pull a subject from the email body ... if it exists,
// do this here because the subject may contain a variable
//
$drop_header = "";
$drop_header = '';
$match = array();
if (preg_match('#^(Subject:(.*?))$#m', $this->msg, $match))
{
@ -193,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]*?' . phpbb_preg_quote($match[1], '#');
$drop_header .= '[\r\n]*?' . preg_quote($match[1], '#');
}
else
{
@ -205,32 +190,22 @@ class emailer
$this->msg = trim(preg_replace('#' . $drop_header . '#s', '', $this->msg));
}
return true;
}
//
// Send the mail out to the recipients set previously in var $this->address
//
function send()
{
global $phpEx, $phpbb_root_path;
if ( $this->address == NULL )
$to = $cc = $bcc = '';
// Build to, cc and bcc strings
@reset($this->addresses);
while (list($type, $address_ary) = each($this->addresses))
{
message_die(GENERAL_ERROR, 'No email address set', '', __LINE__, __FILE__);
@reset($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'] . '>');
}
}
if ( !$this->parse_email() )
{
return false;
}
//
// Add date and encoding type
//
$universal_extra = "MIME-Version: 1.0\nContent-type: text/plain; charset=" . $this->encoding . "\nContent-transfer-encoding: 8bit\nDate: " . gmdate('D, d M Y H:i:s', time()) . " UT\nX-Priority: 3\nX-MSMail-Priority: Normal\nX-Mailer: PHP\n";
$this->extra_headers = $universal_extra . trim($this->extra_headers);
// 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);
// Send message ... removed $this->encode() from subject for time being
if ( $this->use_smtp )
{
if ( !defined('SMTP_INCLUDED') )
@ -238,21 +213,50 @@ class emailer
include($phpbb_root_path . 'includes/smtp.' . $phpEx);
}
$result = smtpmail($this->address, $this->subject, $this->msg, $this->extra_headers);
$result = smtpmail($to, $this->subject, $this->msg, $this->extra_headers);
}
else
{
$result = @mail($this->address, $this->subject, $this->msg, $this->extra_headers);
$result = @mail($to, $this->subject, preg_replace("#(?<!\r)\n#s", "\r\n", $this->msg), $this->extra_headers);
}
if ( !$result )
// Did it work?
if (!$result)
{
message_die(GENERAL_ERROR, 'Failed sending email :: ' . $result, '', __LINE__, __FILE__);
message_die(GENERAL_ERROR, 'Failed sending email :: ' . (($this->use_smtp) ? 'SMTP' : 'PHP') . ' :: ' . $result, '', __LINE__, __FILE__);
}
return true;
}
// Encodes the given string for proper display for this encoding ... nabbed
// from php.net and modified. There is an alternative encoding method which
// may produce lesd output but it's questionable as to its worth in this
// scenario IMO
function encode($str)
{
if ($this->encoding == '')
{
return $str;
}
// define start delimimter, end delimiter and spacer
$end = "?=";
$start = "=?$this->encoding?B?";
$spacer = "$end\r\n $start";
// determine length of encoded text within chunks and ensure length is even
$length = 75 - strlen($start) - strlen($end);
$length = floor($length / 2) * 2;
// encode the string and split it into chunks with spacers after each chunk
$str = chunk_split(base64_encode($str), $length, $spacer);
// remove trailing spacer and add start and end delimiters
$str = preg_replace('#' . preg_quote($spacer) . '$#', '', $str);
return $start . $str . $end;
}
//
// Attach files via MIME.
@ -262,7 +266,7 @@ class emailer
global $lang;
$mime_boundary = "--==================_846811060==_";
$this->mailMsg = '--' . $mime_boundary . "\nContent-Type: text/plain;\n\tcharset=\"" . $lang['ENCODING'] . "\"\n\n" . $this->mailMsg;
$this->msg = '--' . $mime_boundary . "\nContent-Type: text/plain;\n\tcharset=\"" . $lang['ENCODING'] . "\"\n\n" . $this->msg;
if ($mime_filename)
{
@ -358,4 +362,4 @@ class emailer
} // class emailer
?>
?>

View file

@ -620,6 +620,7 @@ function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topi
$update_watched_sql = '';
$bcc_list_ary = array();
if ($row = $db->sql_fetchrow($result))
{
// Sixty second limit
@ -629,7 +630,7 @@ function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topi
{
if ($row['user_email'] != '')
{
$bcc_list_ary[$row['user_lang']] .= (($bcc_list_ary[$row['user_lang']] != '') ? ', ' : '') . $row['user_email'];
$bcc_list_ary[$row['user_lang']][] = $row['user_email'];
}
$update_watched_sql .= ($update_watched_sql != '') ? ', ' . $row['user_id'] : $row['user_id'];
}
@ -654,31 +655,36 @@ function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topi
include($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']);
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
$script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path']));
$script_name = ($script_name != '') ? $script_name . '/viewtopic.'.$phpEx : 'viewtopic.'.$phpEx;
$server_name = trim($board_config['server_name']);
$server_protocol = ($board_config['cookie_secure']) ? 'https://' : 'http://';
$server_port = ($board_config['server_port'] <> 80) ? ':' . trim($board_config['server_port']) . '/' : '/';
$email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\n";
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
$emailer->from($board_config['board_email']);
$emailer->replyto($board_config['board_email']);
$topic_title = (count($orig_word)) ? preg_replace($orig_word, $replacement_word, unprepare_message($topic_title)) : unprepare_message($topic_title);
@reset($bcc_list_ary);
while (list($user_lang, $bcc_list) = each($bcc_list_ary))
{
$emailer->use_template('topic_notify', $user_lang);
$emailer->email_address(':;', 'Topic_reply_notification', $user_lang);
for ($i = 0; $i < count($bcc); $i++)
{
$emailer->bcc($bcc_list[$i]);
}
// The Topic_reply_notification lang string below will be used
// if for some reason the mail template subject cannot be read
// ... note it will not necessarily be in the posters own language!
$emailer->set_subject($lang['Topic_reply_notification']);
$emailer->extra_headers($email_headers . "Bcc: $bcc_list\n");
// This is a nasty kludge to remove the username var ... till (if?)
// translators update their templates
$emailer->msg = preg_replace('#[ ]?{USERNAME}#', '', $emailer->msg);

View file

@ -78,7 +78,7 @@ function clean_words($mode, &$entry, &$stopword_list, &$synonym_list)
if ( $mode == 'post' || ( $stopword != 'not' && $stopword != 'and' && $stopword != 'or' ) )
{
$entry = preg_replace('#\b' . preg_quote($stopword) . '\b#', ' ', $entry);
$entry = str_replace(' ' . trim($stopword) . ' ', ' ', $entry);
}
}
}
@ -90,7 +90,7 @@ function clean_words($mode, &$entry, &$stopword_list, &$synonym_list)
list($replace_synonym, $match_synonym) = split(' ', trim(strtolower($synonym_list[$j])));
if ( $mode == 'post' || ( $match_synonym != 'not' && $match_synonym != 'and' && $match_synonym != 'or' ) )
{
$entry = preg_replace('#\b' . trim($match_synonym) . '\b#', ' ' . trim($replace_synonym) . ' ', $entry);
$entry = str_replace(' ' . trim($match_synonym) . ' ', ' ' . trim($replace_synonym) . ' ', $entry);
}
}
}
@ -100,10 +100,24 @@ function clean_words($mode, &$entry, &$stopword_list, &$synonym_list)
function split_words(&$entry, $mode = 'post')
{
// If you experience problems with the new method, uncomment this block.
/*
$rex = ( $mode == 'post' ) ? "/\b([\w±µ-ÿ][\w±µ-ÿ']*[\w±µ-ÿ]+|[\w±µ-ÿ]+?)\b/" : '/(\*?[a-z0-9±µ-ÿ]+\*?)|\b([a-z0-9±µ-ÿ]+)\b/';
preg_match_all($rex, $entry, $split_entries);
return $split_entries[1];
*/
$split_entries = array();
$split = explode(' ', $entry);
for ($i = 0; $i < count($split); $i++)
{
if (trim($split[$i]) != '')
{
$split_entries[] = trim($split[$i]);
}
}
return $split_entries;
}
function add_search_words($mode, $post_id, $post_text, $post_title = '')

View file

@ -335,6 +335,10 @@ while( list($nav_item, $nav_array) = @each($nav_links) )
}
}
// Format Timezone. We are unable to use array_pop here, because of PHP3 compatibility
$l_timezone = explode('.', $board_config['board_timezone']);
$l_timezone = ($l_timezone[count($l_timezone)-1] != 0) ? $lang[sprintf('%.1f', $board_config['board_timezone'])] : $lang[number_format($board_config['board_timezone'])];
//
// The following assigns all _common_ variables that may be used at any point
// in a template.
@ -395,7 +399,7 @@ $template->assign_vars(array(
'S_CONTENT_ENCODING' => $lang['ENCODING'],
'S_CONTENT_DIR_LEFT' => $lang['LEFT'],
'S_CONTENT_DIR_RIGHT' => $lang['RIGHT'],
'S_TIMEZONE' => sprintf($lang['All_times'], $lang[number_format($board_config['board_timezone'])]),
'S_TIMEZONE' => sprintf($lang['All_times'], $l_timezone),
'S_LOGIN_ACTION' => append_sid('login.'.$phpEx),
'T_HEAD_STYLESHEET' => $theme['head_stylesheet'],

View file

@ -20,6 +20,7 @@
***************************************************************************/
define('SMTP_INCLUDED', 1);
//
// This function has been modified as provided
// by SirSir to allow multiline responses when
@ -41,31 +42,19 @@ function server_parse($socket, $response)
}
}
/****************************************************************************
* Function: smtpmail
* Description: This is a functional replacement for php's builtin mail
* function, that uses smtp.
* Usage: The usage for this function is identical to that of php's
* built in mail function.
****************************************************************************/
function smtpmail($mail_to, $subject, $message, $headers = "")
// Replacement or substitute for PHP's mail command
function smtpmail($mail_to, $subject, $message, $headers = '')
{
// For now I'm using an array based $smtp_vars to hold the smtp server
// info, but it should probably change to $board_config...
// then the relevant info would be $board_config['smtp_host'] and
// $board_config['smtp_port'].
global $board_config;
//
// Fix any bare linefeeds in the message to make it RFC821 Compliant.
//
$message = preg_replace("/(?<!\r)\n/si", "\r\n", $message);
$message = preg_replace("#(?<!\r)\n#si", "\r\n", $message);
if ($headers != "")
if ($headers != '')
{
if(is_array($headers))
if (is_array($headers))
{
if(sizeof($headers) > 1)
if (sizeof($headers) > 1)
{
$headers = join("\r\n", $headers);
}
@ -76,79 +65,77 @@ function smtpmail($mail_to, $subject, $message, $headers = "")
}
$headers = chop($headers);
//
// Make sure there are no bare linefeeds in the headers
//
$headers = preg_replace("/(?<!\r)\n/si", "\r\n", $headers);
//
$headers = preg_replace('#(?<!\r)\n#si', "\r\n", $headers);
// Ok this is rather confusing all things considered,
// but we have to grab bcc and cc headers and treat them differently
// Something we really didn't take into consideration originally
//
$header_array = explode("\r\n", $headers);
@reset($header_array);
$headers = "";
while( list(, $header) = each($header_array) )
$headers = '';
while(list(, $header) = each($header_array))
{
if( preg_match("/^cc:/si", $header) )
if (preg_match('#^cc:#si', $header))
{
$cc = preg_replace("/^cc:(.*)/si", "\\1", $header);
$cc = preg_replace('#^cc:(.*)#si', '\1', $header);
}
else if( preg_match("/^bcc:/si", $header ))
else if (preg_match('#^bcc:#si', $header))
{
$bcc = preg_replace("/^bcc:(.*)/si", "\\1", $header);
$header = "";
$bcc = preg_replace('#^bcc:(.*)#si', '\1', $header);
$header = '';
}
$headers .= $header . "\r\n";
}
$headers = chop($headers);
$cc = explode(",", $cc);
$bcc = explode(",", $bcc);
$cc = explode(',', $cc);
$bcc = explode(',', $bcc);
}
if($mail_to == "")
{
message_die(GENERAL_ERROR, "No email address specified", "", __LINE__, __FILE__);
}
if(trim($subject) == "")
if (trim($subject) == '')
{
message_die(GENERAL_ERROR, "No email Subject specified", "", __LINE__, __FILE__);
}
if(trim($message) == "")
if (trim($message) == '')
{
message_die(GENERAL_ERROR, "Email message was blank", "", __LINE__, __FILE__);
}
$mail_to_array = explode(",", $mail_to);
//
$mail_to_array = explode(',', $mail_to);
// Ok we have error checked as much as we can to this point let's get on
// it already.
//
if( !$socket = fsockopen($board_config['smtp_host'], 25, $errno, $errstr, 20) )
{
message_die(GENERAL_ERROR, "Could not connect to smtp host : $errno : $errstr", "", __LINE__, __FILE__);
}
// Wait for reply
server_parse($socket, "220");
// 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']) )
{
// Send the RFC2554 specified EHLO.
// This improved as provided by SirSir to accomodate
// both SMTP AND ESMTP capable servers
fputs($socket, "EHLO " . $board_config['smtp_host'] . "\r\n");
server_parse($socket, "250");
fputs($socket, "EHLO " . $board_config['smtp_host'] . "\r\n");
server_parse($socket, "250");
fputs($socket, "AUTH LOGIN\r\n");
server_parse($socket, "334");
fputs($socket, base64_encode($board_config['smtp_username']) . "\r\n");
server_parse($socket, "334");
fputs($socket, base64_encode($board_config['smtp_password']) . "\r\n");
server_parse($socket, "235");
}
else
{
// Send the RFC821 specified HELO.
fputs($socket, "HELO " . $board_config['smtp_host'] . "\r\n");
server_parse($socket, "250");
fputs($socket, "AUTH LOGIN\r\n");
server_parse($socket, "334");
fputs($socket, base64_encode($board_config['smtp_username']) . "\r\n");
server_parse($socket, "334");
fputs($socket, base64_encode($board_config['smtp_password']) . "\r\n");
server_parse($socket, "235");
}
else
{
fputs($socket, "HELO " . $board_config['smtp_host'] . "\r\n");
server_parse($socket, "250");
}
// From this point onward most server response codes should be 250
@ -157,48 +144,43 @@ function smtpmail($mail_to, $subject, $message, $headers = "")
server_parse($socket, "250");
// Specify each user to send to and build to header.
$to_header = "To: ";
@reset( $mail_to_array );
while( list( , $mail_to_address ) = each( $mail_to_array ))
@reset($mail_to_array);
while(list(, $mail_to_address) = each($mail_to_array))
{
//
// Add an additional bit of error checking to the To field.
//
$mail_to_address = trim($mail_to_address);
if ( preg_match('/[^ ]+\@[^ ]+/', $mail_to_address) )
if (preg_match('#[^ ]+\@[^ ]+#', $mail_to_address))
{
fputs( $socket, "RCPT TO: <$mail_to_address>\r\n" );
server_parse( $socket, "250" );
fputs($socket, "RCPT TO: $mail_to_address\r\n");
server_parse($socket, "250");
}
$to_header .= ( ( $mail_to_address != '' ) ? ', ' : '' ) . "<$mail_to_address>";
$to_header .= (($to_header !='') ? ', ' : '') . "$mail_to_address";
}
// Ok now do the CC and BCC fields...
@reset( $bcc );
while( list( , $bcc_address ) = each( $bcc ))
@reset($bcc);
while(list(, $bcc_address) = each($bcc))
{
//
// Add an additional bit of error checking to bcc header...
//
$bcc_address = trim( $bcc_address );
if ( preg_match('/[^ ]+\@[^ ]+/', $bcc_address) )
$bcc_address = trim($bcc_address);
if (preg_match('#[^ ]+\@[^ ]+#', $bcc_address))
{
fputs( $socket, "RCPT TO: <$bcc_address>\r\n" );
server_parse( $socket, "250" );
}
}
@reset( $cc );
while( list( , $cc_address ) = each( $cc ))
{
//
// Add an additional bit of error checking to cc header
//
$cc_address = trim( $cc_address );
if ( preg_match('/[^ ]+\@[^ ]+/', $cc_address) )
{
fputs($socket, "RCPT TO: <$cc_address>\r\n");
fputs($socket, "RCPT TO: $bcc_address\r\n");
server_parse($socket, "250");
}
}
@reset($cc);
while(list(, $cc_address) = each($cc))
{
// Add an additional bit of error checking to cc header
$cc_address = trim($cc_address);
if (preg_match('#[^ ]+\@[^ ]+#', $cc_address))
{
fputs($socket, "RCPT TO: $cc_address\r\n");
server_parse($socket, "250");
}
}
// Ok now we tell the server we are ready to start sending data
fputs($socket, "DATA\r\n");
@ -209,7 +191,8 @@ function smtpmail($mail_to, $subject, $message, $headers = "")
fputs($socket, "Subject: $subject\r\n");
// Now the To Header.
fputs($socket, "$to_header\r\n");
$to_header = ($to_header == '') ? "<Undisclosed-recipients:;>" : $to_header;
fputs($socket, "To: $to_header\r\n");
// Now any custom headers....
fputs($socket, "$headers\r\n\r\n");
@ -228,4 +211,4 @@ function smtpmail($mail_to, $subject, $message, $headers = "")
return TRUE;
}
?>
?>

View file

@ -62,12 +62,12 @@ if ( $row = $db->sql_fetchrow($result) )
include($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']);
$email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\n";
$emailer->from($board_config['board_email']);
$emailer->replyto($board_config['board_email']);
$emailer->use_template('admin_welcome_activated', $row['user_lang']);
$emailer->email_address($row['user_email']);
$emailer->set_subject($lang['Account_activated_subject']);
$emailer->extra_headers($email_headers);
$emailer->assign_vars(array(
'SITENAME' => $board_config['sitename'],

View file

@ -99,8 +99,10 @@ if ( $result = $db->sql_query($sql) )
include($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']);
$email_headers = 'Return-Path: ' . $userdata['user_email'] . "\nFrom: " . $userdata['user_email'] . "\n";
$email_headers .= 'X-AntiAbuse: Board servername - ' . $server_name . "\n";
$emailer->from($userdata['user_email']);
$emailer->replyto($userdata['user_email']);
$email_headers = 'X-AntiAbuse: Board servername - ' . $server_name . "\n";
$email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "\n";
$email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "\n";
$email_headers .= 'X-AntiAbuse: User IP - ' . decode_ip($user_ip) . "\n";
@ -122,11 +124,11 @@ if ( $result = $db->sql_query($sql) )
if ( !empty($HTTP_POST_VARS['cc_email']) )
{
$email_headers = 'Return-Path: ' . $userdata['user_email'] . "\nFrom: " . $userdata['user_email'] . "\n";
$emailer->from($userdata['user_email']);
$emailer->replyto($userdata['user_email']);
$emailer->use_template('profile_send_email');
$emailer->email_address($userdata['user_email']);
$emailer->set_subject($subject);
$emailer->extra_headers($email_headers);
$emailer->assign_vars(array(
'SITENAME' => $board_config['sitename'],

View file

@ -457,12 +457,12 @@ if ( isset($HTTP_POST_VARS['submit']) )
include($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']);
$email_headers = "From: " . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\n";
$emailer->from($board_config['board_email']);
$emailer->replyto($board_config['board_email']);
$emailer->use_template('user_activate', stripslashes($user_lang));
$emailer->email_address($email);
$emailer->set_subject($lang['Reactivate']);
$emailer->extra_headers($email_headers);
$emailer->assign_vars(array(
'SITENAME' => $board_config['sitename'],
@ -565,12 +565,12 @@ if ( isset($HTTP_POST_VARS['submit']) )
include($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']);
$email_headers = "From: " . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\n";
$emailer->from($board_config['board_email']);
$emailer->replyto($board_config['board_email']);
$emailer->use_template($email_template, stripslashes($user_lang));
$emailer->email_address($email);
$emailer->set_subject(sprintf($lang['Welcome_subject'], $board_config['sitename']));
$emailer->extra_headers($email_headers);
if( $coppa )
{

View file

@ -65,12 +65,12 @@ if ( isset($HTTP_POST_VARS['submit']) )
include($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']);
$email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\n";
$emailer->from($board_config['board_email']);
$emailer->replyto($board_config['board_email']);
$emailer->use_template('user_activate_passwd', $row['user_lang']);
$emailer->email_address($row['user_email']);
$emailer->set_subject($lang['New_password_activation']);
$emailer->extra_headers($email_headers);
$emailer->assign_vars(array(
'SITENAME' => $board_config['sitename'],

View file

@ -67,7 +67,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('record_online_date
INSERT INTO phpbb_config (config_name, config_value) VALUES ('server_name', 'www.yourdomain.tld');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('server_port', '80');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('script_path', '/phpBB2/');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '.0.4');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '.0.5');
/*
-- Categories

View file

@ -60,7 +60,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('record_online_date
INSERT INTO phpbb_config (config_name, config_value) VALUES ('server_name', 'www.myserver.tld');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('server_port', '80');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('script_path', '/phpBB2/');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '.0.4');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '.0.5');
# -- Categories

View file

@ -61,7 +61,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('record_online_date
INSERT INTO phpbb_config (config_name, config_value) VALUES ('server_name', 'www.yourdomain.tld');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('server_port', '80');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('script_path', '/phpBB2/');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '.0.4');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '.0.5');
-- Categories
INSERT INTO phpbb_categories (cat_id, cat_title, cat_order) VALUES (1, 'Test category 1', 10);

View file

@ -1300,8 +1300,6 @@ else if ( $submit || $refresh || $mode != '' )
if ( $to_userdata['user_notify_pm'] && !empty($to_userdata['user_email']) && $to_userdata['user_active'] )
{
$email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\n";
$script_name = preg_replace('/^\/?(.*?)\/?$/', "\\1", trim($board_config['script_path']));
$script_name = ( $script_name != '' ) ? $script_name . '/privmsg.'.$phpEx : 'privmsg.'.$phpEx;
$server_name = trim($board_config['server_name']);
@ -1311,8 +1309,10 @@ else if ( $submit || $refresh || $mode != '' )
include($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']);
$emailer->from($board_config['board_email']);
$emailer->replyto($board_config['board_email']);
$emailer->use_template('privmsg_notify', $to_userdata['user_lang']);
$emailer->extra_headers($email_headers);
$emailer->email_address($to_userdata['user_email']);
$emailer->set_subject($lang['Notification_subject']);

View file

@ -1,5 +1,5 @@
<form action="{S_LOGIN_ACTION}" method="post" target="_top">
<form action="{S_LOGIN_ACTION}" method="post">
<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
<tr>