mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-15 21:44:56 +01:00
some small changes to mailing again (to better cope with invalid email addresses)
git-svn-id: file:///svn/phpbb/trunk@4805 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
742f5d4a18
commit
719c572ca9
@ -120,28 +120,21 @@ if (isset($_POST['submit']))
|
||||
|
||||
// Send the messages
|
||||
include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx);
|
||||
|
||||
$messenger = new messenger($use_queue);
|
||||
|
||||
$errored = false;
|
||||
|
||||
for ($i = 0; $i < sizeof($email_list); $i++)
|
||||
{
|
||||
$used_lang = $email_list[$i][0]['lang'];
|
||||
$used_method = $email_list[$i][0]['method'];
|
||||
|
||||
if (sizeof($email_list[$i]) == 1)
|
||||
for ($j = 0; $j < sizeof($email_list[$i]); $j++)
|
||||
{
|
||||
$messenger->to($email_list[$i][0]['email'], $email_list[$i][0]['name']);
|
||||
$messenger->im($email_list[$i][0]['jabber'], $email_list[$i][0]['name']);
|
||||
}
|
||||
else
|
||||
{
|
||||
for ($j = 0; $j < sizeof($email_list[$i]); $j++)
|
||||
{
|
||||
$email_row = $email_list[$i][$j];
|
||||
$email_row = $email_list[$i][$j];
|
||||
|
||||
$messenger->bcc($email_row['email'], $email_row['name']);
|
||||
$messenger->im($email_row['jabber'], $email_row['name']);
|
||||
}
|
||||
$messenger->{((sizeof($email_list[$i]) == 1) ? 'to' : 'bcc')}($email_row['email'], $email_row['name']);
|
||||
$messenger->im($email_row['jabber'], $email_row['name']);
|
||||
}
|
||||
|
||||
$messenger->template('admin_send_email', $used_lang);
|
||||
@ -161,7 +154,10 @@ if (isset($_POST['submit']))
|
||||
'MESSAGE' => $message)
|
||||
);
|
||||
|
||||
$messenger->send($used_method, $log_session);
|
||||
if (!($messenger->send($used_method, $log_session)))
|
||||
{
|
||||
$errored = true;
|
||||
}
|
||||
}
|
||||
unset($email_list);
|
||||
|
||||
@ -189,7 +185,8 @@ if (isset($_POST['submit']))
|
||||
}
|
||||
|
||||
add_log('admin', 'LOG_MASS_EMAIL', $group_name);
|
||||
trigger_error($user->lang['EMAIL_SENT']);
|
||||
$message = (!$errored) ? $user->lang['EMAIL_SENT'] : sprintf($user->lang['EMAIL_SEND_ERROR'], '<a href="admin_viewlogs.' . $phpEx . $SID . '&mode=critical" class="gen">', '</a>');
|
||||
trigger_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,20 +48,20 @@ class messenger
|
||||
{
|
||||
$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);
|
||||
$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 im($address, $realname = '')
|
||||
@ -112,7 +112,7 @@ class messenger
|
||||
$template_lang = $config['default_lang'];
|
||||
}
|
||||
|
||||
if (empty($this->tpl_msg["$template_lang$template_file"]))
|
||||
if (empty($this->tpl_msg[$template_lang . $template_file]))
|
||||
{
|
||||
$tpl_file = "{$phpbb_root_path}language/$template_lang/email/$template_file.txt";
|
||||
|
||||
@ -131,11 +131,11 @@ class messenger
|
||||
trigger_error("Failed opening template file [ $template_file ]", E_USER_ERROR);
|
||||
}
|
||||
|
||||
$this->tpl_msg["$template_lang$template_file"] = fread($fd, filesize($tpl_file));
|
||||
$this->tpl_msg[$template_lang . $template_file] = fread($fd, filesize($tpl_file));
|
||||
fclose($fd);
|
||||
}
|
||||
|
||||
$this->msg = $this->tpl_msg["$template_lang$template_file"];
|
||||
$this->msg = $this->tpl_msg[$template_lang . $template_file];
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -201,18 +201,19 @@ class messenger
|
||||
switch ($method)
|
||||
{
|
||||
case NOTIFY_EMAIL:
|
||||
$this->msg_email($log_session);
|
||||
$result = $this->msg_email($log_session);
|
||||
break;
|
||||
case NOTIFY_IM:
|
||||
$this->msg_jabber();
|
||||
$result = $this->msg_jabber();
|
||||
break;
|
||||
case NOTIFY_BOTH:
|
||||
$this->msg_email($log_session);
|
||||
$result = $this->msg_email($log_session);
|
||||
$this->msg_jabber();
|
||||
break;
|
||||
}
|
||||
|
||||
$this->reset();
|
||||
return $result;
|
||||
}
|
||||
|
||||
function error($type, $msg)
|
||||
@ -295,14 +296,13 @@ class messenger
|
||||
$mail_to = ($to == '') ? 'Undisclosed-Recipient:;' : $to;
|
||||
$err_msg = '';
|
||||
|
||||
$result = ($config['smtp_delivery']) ? smtpmail($this->addresses, $this->subject, wordwrap($this->msg), $err_msg, $headers) : @$config['mail_function_name']($mail_to, $this->subject, implode("\n", preg_split("/\r?\n/", wordwrap($this->msg))), $headers);
|
||||
$result = ($config['smtp_delivery']) ? smtpmail($this->addresses, $this->subject, wordwrap($this->msg), $err_msg, $headers, $log_session) : @$config['email_function_name']($mail_to, $this->subject, implode("\n", preg_split("/\r?\n/", wordwrap($this->msg))), $headers);
|
||||
|
||||
if (!$result)
|
||||
{
|
||||
$message = '<u>EMAIL ERROR</u> [ ' . (($config['smtp_delivery']) ? 'SMTP' : 'PHP') . ' ]<br /><br />' . $err_msg . '<br /><br /><u>CALLING PAGE</u><br /><br />' . ((!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF']) . '<br />';
|
||||
|
||||
$this->error('EMAIL', $message);
|
||||
// trigger_error($message, E_USER_ERROR);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -317,6 +317,7 @@ class messenger
|
||||
'headers' => $headers)
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -499,7 +500,7 @@ class queue
|
||||
$err_msg = '';
|
||||
$to = (!$to) ? 'Undisclosed-Recipient:;' : $to;
|
||||
|
||||
$result = ($config['smtp_delivery']) ? smtpmail($addresses, $subject, wordwrap($msg), $err_msg, $headers) : $config['email_function_name']($to, $subject, implode("\n", preg_split("/\r?\n/", wordwrap($msg))), $headers);
|
||||
$result = ($config['smtp_delivery']) ? smtpmail($addresses, $subject, wordwrap($msg), $err_msg, $headers, $log_session) : @$config['email_function_name']($to, $subject, implode("\n", preg_split("/\r?\n/", wordwrap($msg))), $headers);
|
||||
|
||||
if (!$result)
|
||||
{
|
||||
@ -620,7 +621,7 @@ class queue
|
||||
// Replacement or substitute for PHP's mail command
|
||||
function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '', $log_session = false)
|
||||
{
|
||||
global $config;
|
||||
global $config, $user;
|
||||
|
||||
// Fix any bare linefeeds in the message to make it RFC821 Compliant.
|
||||
$message = preg_replace("#(?<!\r)\n#si", "\r\n", $message);
|
||||
@ -689,7 +690,7 @@ function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '', $log
|
||||
$smtp = new smtp_class;
|
||||
|
||||
$smtp->log_session = $log_session;
|
||||
|
||||
|
||||
if ($smtp->log_session)
|
||||
{
|
||||
$smtp->session = 'Connecting to ' . $config['smtp_host'] . ':' . $config['smtp_port'] . "\r\n";
|
||||
@ -760,6 +761,7 @@ function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '', $log
|
||||
// We try to send messages even if a few people do not seem to have valid email addresses, but if no one has, we have to exit here.
|
||||
if (!$rcpt)
|
||||
{
|
||||
$err_msg .= '<br /><br />' . sprintf($user->lang['INVALID_EMAIL_LOG'], htmlspecialchars($mail_to_address));
|
||||
$smtp->close_session();
|
||||
return false;
|
||||
}
|
||||
|
@ -1169,7 +1169,8 @@ $lang += array(
|
||||
'ALL_USERS' => 'All Users',
|
||||
'NO_EMAIL_SUBJECT' => 'You must specify a subject for your message.',
|
||||
'NO_EMAIL_MESSAGE' => 'You must enter a message.',
|
||||
'EMAIL_SENT' => 'Your message has been queued for sending.',
|
||||
'EMAIL_SENT' => 'Your message has been queued for sending.',
|
||||
'EMAIL_SEND_ERROR' => 'There were one or more errors while sending the email. Please check the %sError Log%s for detailed error messages.',
|
||||
'SEND_IMMEDIATLY' => 'Send immediatly',
|
||||
'LOG_SESSION' => 'Log Mail Session',
|
||||
'MAIL_PRIORITY' => 'Mail Priority',
|
||||
|
@ -1356,7 +1356,9 @@ $lang += array(
|
||||
'LOG_DELETE_TOPIC' => '<b>Deleted topic</b><br />» %s',
|
||||
'LOG_APPROVE_TOPIC' => '<b>Approved topic</b><br />» %s',
|
||||
'LOG_UNRATE' => '<b>Unrated post</b><br />» %s',
|
||||
'LOG_TOPIC_RESYNC' => '<b>Resynchronised topic counters</b><br />» %s'
|
||||
'LOG_TOPIC_RESYNC' => '<b>Resynchronised topic counters</b><br />» %s',
|
||||
|
||||
'INVALID_EMAIL_LOG' => '<b>%s</b> possibly an invalid email address?'
|
||||
);
|
||||
|
||||
//---- mcp_main
|
||||
|
Loading…
x
Reference in New Issue
Block a user