- Show SMTP errors in browser (#1485927)

release-0.6
alecpl 15 years ago
parent 2f2bb4020b
commit 2818f8e9ed

@ -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)

@ -49,7 +49,7 @@ $SMTP_CONN = null;
*
* @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 @@ function smtp_mail($from, $recipients, &$headers, &$body, &$response)
$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 @@ function smtp_mail($from, $recipients, &$headers, &$body, &$response)
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 @@ function smtp_mail($from, $recipients, &$headers, &$body, &$response)
// 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 @@ function smtp_mail($from, $recipients, &$headers, &$body, &$response)
$recipients = smtp_parse_rfc822($recipients);
if (PEAR::isError($recipients))
{
$error = array('label' => 'smtprecipientserror');
smtp_reset();
return FALSE;
}
@ -180,8 +184,9 @@ function smtp_mail($from, $recipients, &$headers, &$body, &$response)
{
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 @@ function smtp_mail($from, $recipients, &$headers, &$body, &$response)
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,7 +224,7 @@ function smtp_reset()
{
global $SMTP_CONN;
if (is_object($SMTP_CONN))
if (is_object($SMTP_CONN) && is_resource($SMTP_CONN->_socket->fp))
{
$SMTP_CONN->rset();
smtp_disconnect();
@ -226,7 +232,6 @@ function smtp_reset()
}
/**
* Disconnect the global SMTP connection and destroy object
* @access public

@ -856,7 +856,7 @@ class Net_SMTP
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');
}
}

@ -97,5 +97,11 @@ $messages['opnotpermitted'] = 'Operation not permitted!';
$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';
?>

@ -97,5 +97,11 @@ $messages['opnotpermitted'] = 'Operation not permitted!';
$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';
?>

@ -102,5 +102,11 @@ $messages['opnotpermitted'] = 'Niedozwolona operacja!';
$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';
?>

@ -1302,7 +1302,7 @@ function rcmail_compose_cleanup()
/**
* 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 @@ function rcmail_deliver_message(&$message, $from, $mailto)
// 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_deliver_message(&$message, $from, $mailto)
}
function rcmail_send_mdn($uid)
function rcmail_send_mdn($uid, &$smtp_error)
{
global $RCMAIL, $IMAP;
@ -1438,7 +1438,7 @@ function rcmail_send_mdn($uid)
$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)
{

@ -441,12 +441,15 @@ if (!$savedraft)
$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');
}

@ -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 @@ if ($sent) {
$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');
}

@ -185,7 +185,6 @@ img
background-position: 0 -75px;
}
#message
{
position: absolute;
@ -201,7 +200,6 @@ img
{
width: 400px;
margin: 0px auto;
height: 22px;
min-height: 22px;
padding: 8px 10px 8px 46px;
}

Loading…
Cancel
Save