alecpl
2009-07-06 2818f8e9ed5e8853e33636ac8efe09e2a4161618
- Show SMTP errors in browser (#1485927)


10 files modified
66 ■■■■ changed files
CHANGELOG 1 ●●●● patch | view | raw | blame | history
program/include/rcube_smtp.inc 23 ●●●●● patch | view | raw | blame | history
program/lib/Net/SMTP.php 2 ●●● patch | view | raw | blame | history
program/localization/en_GB/messages.inc 6 ●●●●● patch | view | raw | blame | history
program/localization/en_US/messages.inc 6 ●●●●● patch | view | raw | blame | history
program/localization/pl_PL/messages.inc 6 ●●●●● patch | view | raw | blame | history
program/steps/mail/func.inc 8 ●●●● patch | view | raw | blame | history
program/steps/mail/sendmail.inc 7 ●●●● patch | view | raw | blame | history
program/steps/mail/sendmdn.inc 5 ●●●● patch | view | raw | blame | history
skins/default/common.css 2 ●●●●● patch | view | raw | blame | history
CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG RoundCube Webmail
===========================
- Show SMTP errors in browser (#1485927)
- Allow WBR tag in HTML message (#1485960)
- Use spl_autoload_register() instead of __autoload (#1485947)
- Add hook for identities listing (#1485958)
program/include/rcube_smtp.inc
@@ -49,7 +49,7 @@
 *
 * @return bool  Returns TRUE on success, or FALSE on error
 */
function smtp_mail($from, $recipients, &$headers, &$body, &$response)
function smtp_mail($from, $recipients, &$headers, &$body, &$response, &$error)
  {
  global $SMTP_CONN, $RCMAIL;
  
@@ -96,8 +96,9 @@
    $result = $SMTP_CONN->connect($smtp_timeout);
    if (PEAR::isError($result))
      {
      $SMTP_CONN = null;
      $response[] = "Connection failed: ".$result->getMessage();
      $error = array('label' => 'smtpconnerror', 'vars' => array('code' => $SMTP_CONN->_code));
      $SMTP_CONN = null;
      return FALSE;
      }
      
@@ -119,8 +120,9 @@
    
      if (PEAR::isError($result))
        {
        smtp_reset();
        $error = array('label' => 'smtpautherror', 'vars' => array('code' => $SMTP_CONN->_code));
        $response[] .= 'Authentication failure: ' . $result->getMessage() . ' (Code: ' . $result->getCode() . ')';
        smtp_reset();
        return FALSE;
        }
      }
@@ -160,8 +162,9 @@
  // set From: address
  if (PEAR::isError($SMTP_CONN->mailFrom($from)))
    {
    smtp_reset();
    $error = array('label' => 'smtpfromerror', 'vars' => array('from' => $from, 'code' => $SMTP_CONN->_code));
    $response[] .= "Failed to set sender '$from'";
    smtp_reset();
    return FALSE;
    }
@@ -170,6 +173,7 @@
  $recipients = smtp_parse_rfc822($recipients);
  if (PEAR::isError($recipients))
    {
    $error = array('label' => 'smtprecipientserror');
    smtp_reset();
    return FALSE;
    }
@@ -180,8 +184,9 @@
    {
    if (PEAR::isError($SMTP_CONN->rcptTo($recipient)))
      {
      smtp_reset();
      $error = array('label' => 'smtptoerror', 'vars' => array('to' => $recipient, 'code' => $SMTP_CONN->_code));
      $response[] .= "Failed to add recipient '$recipient'";
      smtp_reset();
      return FALSE;
      }
    }
@@ -197,10 +202,11 @@
  unset($text_headers, $body);
   
  // Send the message's headers and the body as SMTP data.
  if (PEAR::isError($SMTP_CONN->data($data)))
  if (PEAR::isError($result = $SMTP_CONN->data($data)))
    {
    smtp_reset();
    $error = array('label' => 'smtperror', 'vars' => array('msg' => $result->getMessage()));
    $response[] .= "Failed to send data";
    smtp_reset();
    return FALSE;
    }
@@ -218,13 +224,12 @@
  {
  global $SMTP_CONN;
  if (is_object($SMTP_CONN))
  if (is_object($SMTP_CONN) && is_resource($SMTP_CONN->_socket->fp))
    {
    $SMTP_CONN->rset();
    smtp_disconnect();
    }
  }
/**
program/lib/Net/SMTP.php
@@ -856,7 +856,7 @@
        if (isset($this->_esmtp['SIZE']) && ($this->_esmtp['SIZE'] > 0)) {
            if (strlen($data) >= $this->_esmtp['SIZE']) {
                $this->disconnect();
                return PEAR::raiseError('Message size excedes the server limit');
                return PEAR::raiseError('Message size exceedes the server limit');
            }
        }
program/localization/en_GB/messages.inc
@@ -97,5 +97,11 @@
$messages['nofromaddress'] = 'Missing e-mail address in selected identity';
$messages['editorwarning'] = 'Switching to the plain text editor will cause all text formatting to be lost. Do you wish to continue?';
$messages['httpreceivedencrypterror'] = 'A fatal configuration error occurred. Contact your administrator immediately. <b>Your message can not be sent.</b>';
$messages['smtpconnerror'] = 'SMTP Error ($code): Connection to server failed';
$messages['smtpautherror'] = 'SMTP Error ($code): Authentication failed';
$messages['smtpfromerror'] = 'SMTP Error ($code): Failed to set sender "$from"';
$messages['smtptoerror'] = 'SMTP Error ($code): Failed to add recipient "$to"';
$messages['smtprecipientserror'] = 'SMTP Error: Unable to parse recipients list';
$messages['smtperror'] = 'SMTP Error: $msg';
?>
program/localization/en_US/messages.inc
@@ -97,5 +97,11 @@
$messages['nofromaddress'] = 'Missing e-mail address in selected identity';
$messages['editorwarning'] = 'Switching to the plain text editor will cause all text formatting to be lost. Do you wish to continue?';
$messages['httpreceivedencrypterror'] = 'A fatal configuration error occurred. Contact your administrator immediately. <b>Your message can not be sent.</b>';
$messages['smtpconnerror'] = 'SMTP Error ($code): Connection to server failed';
$messages['smtpautherror'] = 'SMTP Error ($code): Authentication failed';
$messages['smtpfromerror'] = 'SMTP Error ($code): Failed to set sender "$from"';
$messages['smtptoerror'] = 'SMTP Error ($code): Failed to add recipient "$to"';
$messages['smtprecipientserror'] = 'SMTP Error: Unable to parse recipients list';
$messages['smtperror'] = 'SMTP Error: $msg';
?>
program/localization/pl_PL/messages.inc
@@ -102,5 +102,11 @@
$messages['nofromaddress'] = 'Brak adresu e-mail w wybranej tożsamości';
$messages['editorwarning'] = 'Zmiana edytora spowoduje utratę formatowania tekstu. Czy jesteś pewien, że chcesz to zrobić?';
$messages['httpreceivedencrypterror'] = 'Wystąpił błąd krytyczny. Skontaktuj się z administratorem. <b>Nie można wysłać wiadomości.</b>';
$messages['smtpconnerror'] = 'Błąd SMTP ($code): Nie można nawiązać połączenia z serwerem';
$messages['smtpautherror'] = 'Błąd SMTP ($code): Uwierzytelnianie nie powiodło się';
$messages['smtpfromerror'] = 'Błąd SMTP ($code): Nie można ustawić nadawcy "$from"';
$messages['smtptoerror'] = 'Błąd SMTP ($code): Nie można dodać odbiorcy "$to"';
$messages['smtprecipientserror'] = 'Błąd SMTP: Parsowanie listy odbiorców nie powiodło się';
$messages['smtperror'] = 'Błąd SMTP: $msg';
?>
program/steps/mail/func.inc
@@ -1302,7 +1302,7 @@
/**
 * Send the given message compose object using the configured method
 */
function rcmail_deliver_message(&$message, $from, $mailto)
function rcmail_deliver_message(&$message, $from, $mailto, &$smtp_error)
{
  global $CONFIG, $RCMAIL;
@@ -1327,7 +1327,7 @@
    // send message
    $smtp_response = array();
    $sent = smtp_mail($from, $a_recipients, ($foo = $message->txtHeaders($send_headers, true)), $msg_body, $smtp_response);
    $sent = smtp_mail($from, $a_recipients, ($foo = $message->txtHeaders($send_headers, true)), $msg_body, $smtp_response, $smtp_error);
    // log error
    if (!$sent)
@@ -1380,7 +1380,7 @@
}
function rcmail_send_mdn($uid)
function rcmail_send_mdn($uid, &$smtp_error)
{
  global $RCMAIL, $IMAP;
@@ -1438,7 +1438,7 @@
    $compose->setTXTBody(rc_wordwrap($body, 75, "\r\n"));
    $compose->addAttachment($report, 'message/disposition-notification', 'MDNPart2.txt', false, '7bit', 'inline');
    $sent = rcmail_deliver_message($compose, $identity['email'], $mailto);
    $sent = rcmail_deliver_message($compose, $identity['email'], $mailto, $smtp_error);
    if ($sent)
    {
program/steps/mail/sendmail.inc
@@ -441,12 +441,15 @@
    $OUTPUT->send('iframe'); 
  }
  $sent = rcmail_deliver_message($MAIL_MIME, $from, $mailto);
  $sent = rcmail_deliver_message($MAIL_MIME, $from, $mailto, $smtp_error);
  
  // return to compose page if sending failed
  if (!$sent)
    {
    $OUTPUT->show_message("sendingfailed", 'error');
    if ($smtp_error)
      $OUTPUT->show_message($smtp_error['label'], 'error', $smtp_error['vars']);
    else
      $OUTPUT->show_message('sendingfailed', 'error');
    $OUTPUT->send('iframe');
    }
program/steps/mail/sendmdn.inc
@@ -21,7 +21,7 @@
if (!empty($_POST['_uid'])) {
  $sent = rcmail_send_mdn(get_input_value('_uid', RCUBE_INPUT_POST));
  $sent = rcmail_send_mdn(get_input_value('_uid', RCUBE_INPUT_POST), $smtp_error);
}
// show either confirm or error message
@@ -29,6 +29,9 @@
  $OUTPUT->set_env('mdn_request', false);
  $OUTPUT->show_message('receiptsent', 'confirmation');
}
else if ($smtp_error) {
  $OUTPUT->show_message($smtp_error['label'], 'error', $smtp_error['vars']);
}
else {
  $OUTPUT->show_message('errorsendingreceipt', 'error');
}
skins/default/common.css
@@ -185,7 +185,6 @@
  background-position: 0 -75px;
}
#message
{
  position: absolute;
@@ -201,7 +200,6 @@
{
  width: 400px;
  margin: 0px auto;
  height: 22px;
  min-height: 22px;
  padding: 8px 10px 8px 46px;
}