The code in this distribution is Copyright 1999-2005 by Hiroyuki Yamamoto
and the Sylpheed-Claws team.
-Specific permission is granted for the GPLed code in this distribition to
-be linked to OpenSSL without invoking GPL clause 2(b).
+As a special exception, the Sylpheed-Claws team gives permission to link
+the code of its release of Sylpheed-Claws with the OpenSSL project's
+"OpenSSL" library (or with modified versions of it that use the same
+license as the "OpenSSL" library), and distribute the linked executables.
+You must obey the GNU General Public License in all respects for all of the
+code used other than "OpenSSL". If you modify this file, you may extend this
+exception to your version of the file, but you are not obliged to do so. If
+you do not wish to do so, delete this exception statement from your version.
-------------------------------------------------------------------------------
GNU GENERAL PUBLIC LICENSE
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
--------------------------------------------------------------------------------
+
+ END OF TERMS AND CONDITIONS
+\f
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
g_free(mail_size);
- session_send_msg(SESSION(session), SESSION_MSG_NORMAL, buf);
+ if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, buf) < 0)
+ return SM_ERROR;
log_print("%sSMTP> %s\n", (session->is_esmtp?"E":""), buf);
return SM_OK;
if (!strncmp(msg, "334 ", 4)) {
base64_encode(buf, session->user, strlen(session->user));
- session_send_msg(SESSION(session), SESSION_MSG_NORMAL,
- buf);
+ if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL,
+ buf) < 0)
+ return SM_ERROR;
log_print("ESMTP> [USERID]\n");
} else {
/* Server rejects AUTH */
- session_send_msg(SESSION(session), SESSION_MSG_NORMAL,
- "*");
+ if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL,
+ "*") < 0)
+ return SM_ERROR;
log_print("ESMTP> *\n");
}
break;
base64_encode(response64, response, strlen(response));
g_free(response);
- session_send_msg(SESSION(session), SESSION_MSG_NORMAL,
- response64);
+ if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL,
+ response64) < 0)
+ return SM_ERROR;
log_print("ESMTP> %s\n", response64);
g_free(response64);
} else {
/* Server rejects AUTH */
- session_send_msg(SESSION(session), SESSION_MSG_NORMAL,
- "*");
+ if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL,
+ "*") < 0)
+ return SM_ERROR;
log_print("ESMTP> *\n");
}
break;
case SMTPAUTH_DIGEST_MD5:
default:
/* stop smtp_auth when no correct authtype */
- session_send_msg(SESSION(session), SESSION_MSG_NORMAL, "*");
+ if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, "*") < 0)
+ return SM_ERROR;
log_print("ESMTP> *\n");
break;
}
/* Server rejects AUTH */
g_snprintf(buf, sizeof(buf), "*");
- session_send_msg(SESSION(session), SESSION_MSG_NORMAL, buf);
+ if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, buf) < 0)
+ return SM_ERROR;
+
log_print("ESMTP> [PASSWORD]\n");
return SM_OK;
g_snprintf(buf, sizeof(buf), "EHLO %s",
session->hostname ? session->hostname : get_domain_name());
- session_send_msg(SESSION(session), SESSION_MSG_NORMAL, buf);
+ if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, buf) < 0)
+ return SM_ERROR;
log_print("ESMTP> %s\n", buf);
return SM_OK;
{
session->state = SMTP_STARTTLS;
- session_send_msg(SESSION(session), SESSION_MSG_NORMAL, "STARTTLS");
+ if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, "STARTTLS") < 0)
+ return SM_ERROR;
log_print("ESMTP> STARTTLS\n");
return SM_OK;
session->state = SMTP_AUTH;
session->auth_type = SMTPAUTH_CRAM_MD5;
- session_send_msg(SESSION(session), SESSION_MSG_NORMAL, "AUTH CRAM-MD5");
+ if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, "AUTH CRAM-MD5") < 0)
+ return SM_ERROR;
log_print("ESMTP> AUTH CRAM-MD5\n");
return SM_OK;
a = buf + strlen(buf);
base64_encode(a, b64buf, b64cnt);
- session_send_msg(SESSION(session), SESSION_MSG_NORMAL, buf);
+ if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, buf) < 0)
+ return SM_ERROR;
log_print("ESMTP> [AUTH PLAIN]\n");
session->state = SMTP_AUTH;
session->auth_type = SMTPAUTH_LOGIN;
- session_send_msg(SESSION(session), SESSION_MSG_NORMAL, "AUTH LOGIN");
+ if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, "AUTH LOGIN") < 0)
+ return SM_ERROR;
log_print("ESMTP> AUTH LOGIN\n");
return SM_OK;
g_snprintf(buf, sizeof(buf), "HELO %s",
session->hostname ? session->hostname : get_domain_name());
- session_send_msg(SESSION(session), SESSION_MSG_NORMAL, buf);
+ if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, buf) < 0)
+ return SM_ERROR;
log_print("SMTP> %s\n", buf);
return SM_OK;
g_snprintf(buf, sizeof(buf), "RCPT TO:%s", to);
else
g_snprintf(buf, sizeof(buf), "RCPT TO:<%s>", to);
- session_send_msg(SESSION(session), SESSION_MSG_NORMAL, buf);
+ if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, buf) < 0)
+ return SM_ERROR;
log_print("SMTP> %s\n", buf);
session->cur_to = session->cur_to->next;
{
session->state = SMTP_DATA;
- session_send_msg(SESSION(session), SESSION_MSG_NORMAL, "DATA");
+ if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, "DATA") < 0)
+ return SM_ERROR;
log_print("SMTP> DATA\n");
return SM_OK;
return SM_OK;
}
-#if 0
-static gint smtp_rset(SMTPSession *session)
-{
- session->state = SMTP_RSET;
-
- session_send_msg(SESSION(session), SESSION_MSG_NORMAL, "RSET");
- log_print("SMTP> RSET\n");
-
- return SM_OK;
-}
-#endif
-
static gint smtp_make_ready(SMTPSession *session)
{
session->state = SMTP_MAIL_SENT_OK;
{
session->state = SMTP_EOM;
- session_send_msg(SESSION(session), SESSION_MSG_NORMAL, ".");
+ if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, ".") < 0)
+ return SM_ERROR;
log_print("SMTP> . (EOM)\n");
return SM_OK;
{
SMTPSession *smtp_session = SMTP_SESSION(session);
gboolean cont = FALSE;
-
+ gint ret = 0;
+
if (strlen(msg) < 4) {
log_warning(_("bad SMTP response\n"));
return -1;
#else
if (smtp_session->user || smtp_session->is_esmtp)
#endif
- smtp_ehlo(smtp_session);
+ ret = smtp_ehlo(smtp_session);
else
- smtp_helo(smtp_session);
+ ret = smtp_helo(smtp_session);
break;
case SMTP_HELO:
- smtp_from(smtp_session);
+ ret = smtp_from(smtp_session);
break;
case SMTP_EHLO:
- smtp_ehlo_recv(smtp_session, msg);
+ ret = smtp_ehlo_recv(smtp_session, msg);
if (cont == TRUE)
break;
if (smtp_session->max_message_size > 0
#if USE_OPENSSL
if (session->ssl_type == SSL_STARTTLS &&
smtp_session->tls_init_done == FALSE) {
- smtp_starttls(smtp_session);
+ ret = smtp_starttls(smtp_session);
break;
}
#endif
if (session->ssl_type == SSL_NONE
&& smtp_session->tls_init_done == FALSE
&& (smtp_session->avail_auth_type & SMTPAUTH_TLS_AVAILABLE))
- smtp_starttls(smtp_session);
+ ret = smtp_starttls(smtp_session);
else
#endif
- smtp_from(smtp_session);
+ ret = smtp_from(smtp_session);
}
} else
- smtp_from(smtp_session);
+ ret = smtp_from(smtp_session);
break;
case SMTP_STARTTLS:
#if USE_OPENSSL
return -1;
}
smtp_session->tls_init_done = TRUE;
- smtp_ehlo(smtp_session);
+ ret = smtp_ehlo(smtp_session);
#endif
break;
case SMTP_AUTH:
- smtp_auth_recv(smtp_session, msg);
+ ret = smtp_auth_recv(smtp_session, msg);
break;
case SMTP_AUTH_LOGIN_USER:
- smtp_auth_login_user_recv(smtp_session, msg);
+ ret = smtp_auth_login_user_recv(smtp_session, msg);
break;
case SMTP_AUTH_PLAIN:
case SMTP_AUTH_LOGIN_PASS:
case SMTP_AUTH_CRAM_MD5:
- smtp_from(smtp_session);
+ ret = smtp_from(smtp_session);
break;
case SMTP_FROM:
if (smtp_session->cur_to)
- smtp_rcpt(smtp_session);
+ ret = smtp_rcpt(smtp_session);
break;
case SMTP_RCPT:
if (smtp_session->cur_to)
- smtp_rcpt(smtp_session);
+ ret = smtp_rcpt(smtp_session);
else
- smtp_data(smtp_session);
+ ret = smtp_data(smtp_session);
break;
case SMTP_DATA:
- smtp_send_data(smtp_session);
+ ret = smtp_send_data(smtp_session);
break;
case SMTP_EOM:
smtp_make_ready(smtp_session);
return -1;
}
- if (cont)
+ if (cont && ret == SM_OK)
return session_recv_msg(session);
- return 0;
+ if (ret != SM_OK)
+ smtp_session->error_val = SM_ERROR;
+
+ return ret == SM_OK ? 0 : -1;
}
static gint smtp_session_send_data_finished(Session *session, guint len)
{
- smtp_eom(SMTP_SESSION(session));
- return 0;
+ return smtp_eom(SMTP_SESSION(session));
}