/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail team
*
* 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
#ifdef HAVE_CONFIG_H
# include "config.h"
+#include "claws-features.h"
#endif
#include <glib.h>
gint smtp_from(SMTPSession *session)
{
- gchar buf[MSGBUFSIZE];
+ gchar buf[MESSAGEBUFSIZE];
gchar *mail_size = NULL;
- g_return_val_if_fail(session->from != NULL, SM_ERROR);
+ cm_return_val_if_fail(session->from != NULL, SM_ERROR);
session->state = SMTP_FROM;
static gint smtp_auth(SMTPSession *session)
{
- g_return_val_if_fail(session->user != NULL, SM_ERROR);
+ cm_return_val_if_fail(session->user != NULL, SM_ERROR);
session->state = SMTP_AUTH;
- if (session->forced_auth_type == SMTPAUTH_CRAM_MD5 ||
- (session->forced_auth_type == 0 &&
- (session->avail_auth_type & SMTPAUTH_CRAM_MD5) != 0))
+ if ((session->forced_auth_type == SMTPAUTH_CRAM_MD5
+ || session->forced_auth_type == 0)
+ &&
+ (session->avail_auth_type & SMTPAUTH_CRAM_MD5) != 0)
smtp_auth_cram_md5(session);
- else if (session->forced_auth_type == SMTPAUTH_LOGIN ||
- (session->forced_auth_type == 0 &&
- (session->avail_auth_type & SMTPAUTH_LOGIN) != 0))
+ else if ((session->forced_auth_type == SMTPAUTH_LOGIN
+ || session->forced_auth_type == 0)
+ &&
+ (session->avail_auth_type & SMTPAUTH_LOGIN) != 0)
smtp_auth_login(session);
- else if (session->forced_auth_type == SMTPAUTH_PLAIN ||
- (session->forced_auth_type == 0 &&
- (session->avail_auth_type & SMTPAUTH_PLAIN) != 0))
+ else if ((session->forced_auth_type == SMTPAUTH_PLAIN
+ || session->forced_auth_type == 0)
+ &&
+ (session->avail_auth_type & SMTPAUTH_PLAIN) != 0)
smtp_auth_plain(session);
- else {
- log_warning(LOG_PROTOCOL, _("SMTP AUTH not available\n"));
+ else if (session->forced_auth_type == 0) {
+ log_warning(LOG_PROTOCOL, _("No SMTP AUTH method available\n"));
+ return SM_AUTHFAIL;
+ } else {
+ log_warning(LOG_PROTOCOL, _("Selected SMTP AUTH method not available\n"));
return SM_AUTHFAIL;
}
static gint smtp_auth_recv(SMTPSession *session, const gchar *msg)
{
- gchar buf[MSGBUFSIZE];
+ gchar buf[MESSAGEBUFSIZE];
switch (session->auth_type) {
case SMTPAUTH_LOGIN:
static gint smtp_auth_login_user_recv(SMTPSession *session, const gchar *msg)
{
- gchar buf[MSGBUFSIZE];
+ gchar buf[MESSAGEBUFSIZE];
session->state = SMTP_AUTH_LOGIN_PASS;
static gint smtp_ehlo(SMTPSession *session)
{
- gchar buf[MSGBUFSIZE];
+ gchar buf[MESSAGEBUFSIZE];
session->state = SMTP_EHLO;
static gint smtp_auth_plain(SMTPSession *session)
{
- gchar buf[MSGBUFSIZE];
+ gchar buf[MESSAGEBUFSIZE];
/*
* +1 +1 +1
static gint smtp_helo(SMTPSession *session)
{
- gchar buf[MSGBUFSIZE];
+ gchar buf[MESSAGEBUFSIZE];
session->state = SMTP_HELO;
static gint smtp_rcpt(SMTPSession *session)
{
- gchar buf[MSGBUFSIZE];
+ gchar buf[MESSAGEBUFSIZE];
gchar *to;
- g_return_val_if_fail(session->cur_to != NULL, SM_ERROR);
+ cm_return_val_if_fail(session->cur_to != NULL, SM_ERROR);
session->state = SMTP_RCPT;
break;
}
+ /* ignore all multiline responses except for EHLO */
+ if (msg[3] == '-' && smtp_session->state != SMTP_EHLO)
+ return session_recv_msg(session);
+
if (msg[0] == '5' && msg[1] == '0' &&
(msg[2] == '4' || msg[2] == '3' || msg[2] == '1')) {
log_warning(LOG_PROTOCOL, _("error occurred on SMTP session\n"));
return -1;
}
- /* ignore all multiline responses except for EHLO */
- if (cont && smtp_session->state != SMTP_EHLO)
- return session_recv_msg(session);
-
switch (smtp_session->state) {
case SMTP_READY:
if (strstr(msg, "ESMTP"))