diff options
Diffstat (limited to 'program')
-rw-r--r-- | program/include/rcube_smtp.inc | 23 | ||||
-rw-r--r-- | program/lib/Net/SMTP.php | 2 | ||||
-rw-r--r-- | program/localization/en_GB/messages.inc | 6 | ||||
-rw-r--r-- | program/localization/en_US/messages.inc | 6 | ||||
-rw-r--r-- | program/localization/pl_PL/messages.inc | 6 | ||||
-rw-r--r-- | program/steps/mail/func.inc | 8 | ||||
-rw-r--r-- | program/steps/mail/sendmail.inc | 7 | ||||
-rw-r--r-- | program/steps/mail/sendmdn.inc | 5 |
8 files changed, 46 insertions, 17 deletions
diff --git a/program/include/rcube_smtp.inc b/program/include/rcube_smtp.inc index b5bd183d8..066e5ed47 100644 --- a/program/include/rcube_smtp.inc +++ b/program/include/rcube_smtp.inc @@ -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 diff --git a/program/lib/Net/SMTP.php b/program/lib/Net/SMTP.php index 550383eef..1248a327b 100644 --- a/program/lib/Net/SMTP.php +++ b/program/lib/Net/SMTP.php @@ -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'); } } diff --git a/program/localization/en_GB/messages.inc b/program/localization/en_GB/messages.inc index 137214b4b..0552591bb 100644 --- a/program/localization/en_GB/messages.inc +++ b/program/localization/en_GB/messages.inc @@ -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'; ?> diff --git a/program/localization/en_US/messages.inc b/program/localization/en_US/messages.inc index ed233b1eb..fa0b30711 100644 --- a/program/localization/en_US/messages.inc +++ b/program/localization/en_US/messages.inc @@ -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'; ?> diff --git a/program/localization/pl_PL/messages.inc b/program/localization/pl_PL/messages.inc index 53926a2b4..168815484 100644 --- a/program/localization/pl_PL/messages.inc +++ b/program/localization/pl_PL/messages.inc @@ -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'; ?> diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index e7eb4b373..a942c1a44 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -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) { diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index d550a422d..c5a2ea7c3 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -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'); } diff --git a/program/steps/mail/sendmdn.inc b/program/steps/mail/sendmdn.inc index 3d7755cf3..c3294e7fe 100644 --- a/program/steps/mail/sendmdn.inc +++ b/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 @@ 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'); } |