Use flags rather than a bunch of gboolean variables. (smtp_connect): Same.

2002-01-28  Jeffrey Stedfast  <fejj@ximian.com>

	* providers/smtp/camel-smtp-transport.c (smtp_construct):
	(connect_to_server): Use flags rather than a bunch of gboolean
	variables.
	(smtp_connect): Same.
	(smtp_mail): Here too. Use the enhanced status codes if available.
	(smtp_data): And again here.
	(smtp_helo): Finally here. Also detect the ENHANCEDSTATUSCODES
	extension.
	(smtp_rcpt): Use the enhanced status codes if available.
	(smtp_rset): Here too.
	(smtp_quit): And finally here.

	* camel-transport.h: Removed gboolean supports_8bit since this is
	pretty local to only SMTP for now.

svn path=/trunk/; revision=15498
This commit is contained in:
Jeffrey Stedfast
2002-01-28 22:10:44 +00:00
committed by Jeffrey Stedfast
parent 84e6a5344f
commit 6861836d29
4 changed files with 171 additions and 73 deletions

View File

@ -1,3 +1,20 @@
2002-01-28 Jeffrey Stedfast <fejj@ximian.com>
* providers/smtp/camel-smtp-transport.c (smtp_construct):
(connect_to_server): Use flags rather than a bunch of gboolean
variables.
(smtp_connect): Same.
(smtp_mail): Here too. Use the enhanced status codes if available.
(smtp_data): And again here.
(smtp_helo): Finally here. Also detect the ENHANCEDSTATUSCODES
extension.
(smtp_rcpt): Use the enhanced status codes if available.
(smtp_rset): Here too.
(smtp_quit): And finally here.
* camel-transport.h: Removed gboolean supports_8bit since this is
pretty local to only SMTP for now.
2002-01-24 Ettore Perazzoli <ettore@ximian.com> 2002-01-24 Ettore Perazzoli <ettore@ximian.com>
* Makefile.am: Remove some old cruft. * Makefile.am: Remove some old cruft.

View File

@ -47,8 +47,6 @@ struct _CamelTransport
CamelService parent_object; CamelService parent_object;
struct _CamelTransportPrivate *priv; struct _CamelTransportPrivate *priv;
gboolean supports_8bit;
}; };

View File

@ -120,18 +120,18 @@ camel_smtp_transport_class_init (CamelSmtpTransportClass *camel_smtp_transport_c
static void static void
camel_smtp_transport_init (gpointer object) camel_smtp_transport_init (gpointer object)
{ {
CamelTransport *transport = CAMEL_TRANSPORT (object); CamelSmtpTransport *smtp = CAMEL_SMTP_TRANSPORT (object);
transport->supports_8bit = FALSE; smtp->flags = 0;
} }
CamelType CamelType
camel_smtp_transport_get_type (void) camel_smtp_transport_get_type (void)
{ {
static CamelType camel_smtp_transport_type = CAMEL_INVALID_TYPE; static CamelType type = CAMEL_INVALID_TYPE;
if (camel_smtp_transport_type == CAMEL_INVALID_TYPE) { if (type == CAMEL_INVALID_TYPE) {
camel_smtp_transport_type = type =
camel_type_register (CAMEL_TRANSPORT_TYPE, camel_type_register (CAMEL_TRANSPORT_TYPE,
"CamelSmtpTransport", "CamelSmtpTransport",
sizeof (CamelSmtpTransport), sizeof (CamelSmtpTransport),
@ -142,7 +142,7 @@ camel_smtp_transport_get_type (void)
NULL); NULL);
} }
return camel_smtp_transport_type; return type;
} }
static void static void
@ -155,7 +155,7 @@ smtp_construct (CamelService *service, CamelSession *session,
CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex); CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex);
if (camel_url_get_param (url, "use_ssl")) if (camel_url_get_param (url, "use_ssl"))
smtp_transport->use_ssl = TRUE; smtp_transport->flags |= CAMEL_SMTP_TRANSPORT_USE_SSL;
} }
static const char * static const char *
@ -245,14 +245,16 @@ connect_to_server (CamelService *service, CamelException *ex)
return FALSE; return FALSE;
/* set some smtp transport defaults */ /* set some smtp transport defaults */
transport->is_esmtp = FALSE; transport->flags &= ~(CAMEL_SMTP_TRANSPORT_IS_ESMTP |
CAMEL_SMTP_TRANSPORT_8BITMIME |
CAMEL_SMTP_TRANSPORT_ENHANCEDSTATUSCODES);
transport->authtypes = NULL; transport->authtypes = NULL;
CAMEL_TRANSPORT (transport)->supports_8bit = FALSE;
port = service->url->port ? service->url->port : SMTP_PORT; port = service->url->port ? service->url->port : SMTP_PORT;
#if defined(HAVE_NSS) || defined(HAVE_OPENSSL) #if defined(HAVE_NSS) || defined(HAVE_OPENSSL)
if (transport->use_ssl) { if (transport->flags & CAMEL_SMTP_TRANSPORT_USE_SSL) {
port = service->url->port ? service->url->port : 465; port = service->url->port ? service->url->port : 465;
#ifdef HAVE_NSS #ifdef HAVE_NSS
/* use the preferred implementation - NSS */ /* use the preferred implementation - NSS */
@ -268,7 +270,7 @@ connect_to_server (CamelService *service, CamelException *ex)
#endif /* HAVE_NSS || HAVE_OPENSSL */ #endif /* HAVE_NSS || HAVE_OPENSSL */
ret = camel_tcp_stream_connect (CAMEL_TCP_STREAM (tcp_stream), h, port); ret = camel_tcp_stream_connect (CAMEL_TCP_STREAM (tcp_stream), h, port);
camel_free_host(h); camel_free_host (h);
if (ret == -1) { if (ret == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("Could not connect to %s (port %d): %s"), _("Could not connect to %s (port %d): %s"),
@ -281,7 +283,7 @@ connect_to_server (CamelService *service, CamelException *ex)
/* get the localaddr - needed later by smtp_helo */ /* get the localaddr - needed later by smtp_helo */
addrlen = sizeof (transport->localaddr); addrlen = sizeof (transport->localaddr);
#ifdef HAVE_NSS #ifdef HAVE_NSS
if (transport->use_ssl) { if (transport->flags & CAMEL_SMTP_TRANSPORT_USE_SSL) {
PRFileDesc *sockfd = camel_tcp_stream_get_socket (CAMEL_TCP_STREAM (tcp_stream)); PRFileDesc *sockfd = camel_tcp_stream_get_socket (CAMEL_TCP_STREAM (tcp_stream));
PRNetAddr addr; PRNetAddr addr;
char hname[1024]; char hname[1024];
@ -320,17 +322,17 @@ connect_to_server (CamelService *service, CamelException *ex)
return FALSE; return FALSE;
} }
if (strstr (respbuf, "ESMTP")) if (strstr (respbuf, "ESMTP"))
transport->is_esmtp = TRUE; transport->flags |= CAMEL_SMTP_TRANSPORT_IS_ESMTP;
} while (*(respbuf+3) == '-'); /* if we got "220-" then loop again */ } while (*(respbuf+3) == '-'); /* if we got "220-" then loop again */
g_free (respbuf); g_free (respbuf);
/* send HELO (or EHLO, depending on the service type) */ /* send HELO (or EHLO, depending on the service type) */
if (!transport->is_esmtp) { if (!(transport->flags & CAMEL_SMTP_TRANSPORT_IS_ESMTP)) {
/* If we did not auto-detect ESMTP, we should still send EHLO */ /* If we did not auto-detect ESMTP, we should still send EHLO */
transport->is_esmtp = TRUE; transport->flags |= CAMEL_SMTP_TRANSPORT_IS_ESMTP;
if (!smtp_helo (transport, NULL)) { if (!smtp_helo (transport, NULL)) {
/* Okay, apprently this server doesn't support ESMTP */ /* Okay, apprently this server doesn't support ESMTP */
transport->is_esmtp = FALSE; transport->flags &= ~CAMEL_SMTP_TRANSPORT_IS_ESMTP;
smtp_helo (transport, ex); smtp_helo (transport, ex);
} }
} else { } else {
@ -375,7 +377,8 @@ smtp_connect (CamelService *service, CamelException *ex)
gboolean authenticated = FALSE; gboolean authenticated = FALSE;
char *errbuf = NULL; char *errbuf = NULL;
if (!transport->is_esmtp || !g_hash_table_lookup (transport->authtypes, service->url->authmech)) { if (!(transport->flags & CAMEL_SMTP_TRANSPORT_IS_ESMTP) ||
!g_hash_table_lookup (transport->authtypes, service->url->authmech)) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
_("SMTP server %s does not support requested " _("SMTP server %s does not support requested "
"authentication type %s"), service->url->host, "authentication type %s"), service->url->host,
@ -545,6 +548,7 @@ query_auth_types (CamelService *service, CamelException *ex)
} }
smtp_disconnect (service, TRUE, NULL); smtp_disconnect (service, TRUE, NULL);
return types; return types;
} }
@ -601,8 +605,7 @@ smtp_send_to (CamelTransport *transport, CamelMedium *message,
if (!recipients) { if (!recipients) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot send message: " _("Cannot send message: no recipients defined."));
"no recipients defined."));
camel_operation_end (NULL); camel_operation_end (NULL);
return FALSE; return FALSE;
} }
@ -664,20 +667,36 @@ smtp_send (CamelTransport *transport, CamelMedium *message, CamelException *ex)
return status; return status;
} }
static const char *
smtp_next_token (const char *buf)
{
const unsigned char *token;
token = (const unsigned char *) buf;
while (*token && !isspace ((int) *token))
token++;
while (*token && isspace ((int) *token))
token++;
return (const char *) token;
}
static gboolean static gboolean
smtp_helo (CamelSmtpTransport *transport, CamelException *ex) smtp_helo (CamelSmtpTransport *transport, CamelException *ex)
{ {
/* say hello to the server */ /* say hello to the server */
gchar *cmdbuf, *respbuf = NULL; char *cmdbuf, *respbuf = NULL;
const char *token;
struct hostent *host; struct hostent *host;
camel_operation_start_transient (NULL, _("SMTP Greeting")); camel_operation_start_transient (NULL, _("SMTP Greeting"));
/* get the local host name */ /* get the local host name */
host = gethostbyaddr ((gchar *)&transport->localaddr.sin_addr, sizeof (transport->localaddr.sin_addr), AF_INET); host = gethostbyaddr ((char *)&transport->localaddr.sin_addr, sizeof (transport->localaddr.sin_addr), AF_INET);
/* hiya server! how are you today? */ /* hiya server! how are you today? */
if (transport->is_esmtp) { if (transport->flags & CAMEL_SMTP_TRANSPORT_IS_ESMTP) {
if (host && host->h_name) if (host && host->h_name)
cmdbuf = g_strdup_printf ("EHLO %s\r\n", host->h_name); cmdbuf = g_strdup_printf ("EHLO %s\r\n", host->h_name);
else else
@ -719,17 +738,28 @@ smtp_helo (CamelSmtpTransport *transport, CamelException *ex)
return FALSE; return FALSE;
} }
if (strstrcase (respbuf, "8BITMIME")) { token = respbuf + 4;
if (transport->flags & CAMEL_SMTP_TRANSPORT_IS_ESMTP) {
if (!strncmp (token, "8BITMIME", 8)) {
d(fprintf (stderr, "This server supports 8bit MIME\n")); d(fprintf (stderr, "This server supports 8bit MIME\n"));
CAMEL_TRANSPORT (transport)->supports_8bit = TRUE; transport->flags |= CAMEL_SMTP_TRANSPORT_8BITMIME;
} } else if (!strncmp (token, "ENHANCEDSTATUSCODES", 19)) {
d(fprintf (stderr, "This server supports enhanced status codes\n"));
transport->flags |= CAMEL_SMTP_TRANSPORT_ENHANCEDSTATUSCODES;
} else if (!transport->authtypes && !strncmp (token, "AUTH", 4)) {
/* Don't bother parsing any authtypes if we already have a list.
* Some servers will list AUTH twice, once the standard way and
* once the way Microsoft Outlook requires them to be:
*
* 250-AUTH LOGIN PLAIN DIGEST-MD5 CRAM-MD5
* 250-AUTH=LOGIN PLAIN DIGEST-MD5 CRAM-MD5
**/
/* Only parse authtypes if we don't already have them */
if (transport->is_esmtp && strstr (respbuf, "AUTH") && !transport->authtypes) {
/* parse for supported AUTH types */ /* parse for supported AUTH types */
char *auths = strstr (respbuf, "AUTH") + 4; token = smtp_next_token (token);
transport->authtypes = esmtp_get_authtypes (token);
transport->authtypes = esmtp_get_authtypes (auths); }
} }
} while (*(respbuf+3) == '-'); /* if we got "250-" then loop again */ } while (*(respbuf+3) == '-'); /* if we got "250-" then loop again */
g_free (respbuf); g_free (respbuf);
@ -742,7 +772,7 @@ smtp_helo (CamelSmtpTransport *transport, CamelException *ex)
static gboolean static gboolean
smtp_auth (CamelSmtpTransport *transport, const char *mech, CamelException *ex) smtp_auth (CamelSmtpTransport *transport, const char *mech, CamelException *ex)
{ {
gchar *cmdbuf, *respbuf = NULL, *challenge; char *cmdbuf, *respbuf = NULL, *challenge;
CamelSasl *sasl = NULL; CamelSasl *sasl = NULL;
camel_operation_start_transient (NULL, _("SMTP Authentication")); camel_operation_start_transient (NULL, _("SMTP Authentication"));
@ -848,10 +878,10 @@ static gboolean
smtp_mail (CamelSmtpTransport *transport, const char *sender, gboolean has_8bit_parts, CamelException *ex) smtp_mail (CamelSmtpTransport *transport, const char *sender, gboolean has_8bit_parts, CamelException *ex)
{ {
/* we gotta tell the smtp server who we are. (our email addy) */ /* we gotta tell the smtp server who we are. (our email addy) */
gchar *cmdbuf, *respbuf = NULL; char *cmdbuf, *respbuf = NULL;
/* enclose address in <>'s since some SMTP daemons *require* that */ /* enclose address in <>'s since some SMTP daemons *require* that */
if (CAMEL_TRANSPORT (transport)->supports_8bit && has_8bit_parts) if (transport->flags & CAMEL_SMTP_TRANSPORT_8BITMIME && has_8bit_parts)
cmdbuf = g_strdup_printf ("MAIL FROM: <%s> BODY=8BITMIME\r\n", sender); cmdbuf = g_strdup_printf ("MAIL FROM: <%s> BODY=8BITMIME\r\n", sender);
else else
cmdbuf = g_strdup_printf ("MAIL FROM: <%s>\r\n", sender); cmdbuf = g_strdup_printf ("MAIL FROM: <%s>\r\n", sender);
@ -875,13 +905,21 @@ smtp_mail (CamelSmtpTransport *transport, const char *sender, gboolean has_8bit_
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)")); d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
if (!respbuf || strncmp (respbuf, "250", 3)) { if (!respbuf || strncmp (respbuf, "250", 3)) {
const char *token;
int error; int error;
if (!respbuf || !(transport->flags & CAMEL_SMTP_TRANSPORT_ENHANCEDSTATUSCODES)) {
error = respbuf ? atoi (respbuf) : 0; error = respbuf ? atoi (respbuf) : 0;
g_free (respbuf); token = get_smtp_error_string (error);
} else
token = respbuf + 4;
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("MAIL FROM response error: %s: mail not sent"), _("MAIL FROM response error: %s"),
get_smtp_error_string (error)); token);
g_free (respbuf);
return FALSE; return FALSE;
} }
} while (*(respbuf+3) == '-'); /* if we got "250-" then loop again */ } while (*(respbuf+3) == '-'); /* if we got "250-" then loop again */
@ -895,7 +933,7 @@ smtp_rcpt (CamelSmtpTransport *transport, const char *recipient, CamelException
{ {
/* we gotta tell the smtp server who we are going to be sending /* we gotta tell the smtp server who we are going to be sending
* our email to */ * our email to */
gchar *cmdbuf, *respbuf = NULL; char *cmdbuf, *respbuf = NULL;
/* enclose address in <>'s since some SMTP daemons *require* that */ /* enclose address in <>'s since some SMTP daemons *require* that */
cmdbuf = g_strdup_printf ("RCPT TO: <%s>\r\n", recipient); cmdbuf = g_strdup_printf ("RCPT TO: <%s>\r\n", recipient);
@ -912,20 +950,28 @@ smtp_rcpt (CamelSmtpTransport *transport, const char *recipient, CamelException
g_free (cmdbuf); g_free (cmdbuf);
do { do {
/* Check for "250 Sender OK..." */ /* Check for "250 Recipient OK..." */
g_free (respbuf); g_free (respbuf);
respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream)); respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream));
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)")); d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
if (!respbuf || strncmp (respbuf, "250", 3)) { if (!respbuf || strncmp (respbuf, "250", 3)) {
const char *token;
int error; int error;
if (!respbuf || !(transport->flags & CAMEL_SMTP_TRANSPORT_ENHANCEDSTATUSCODES)) {
error = respbuf ? atoi (respbuf) : 0; error = respbuf ? atoi (respbuf) : 0;
g_free (respbuf); token = get_smtp_error_string (error);
} else
token = respbuf + 4;
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("RCPT TO response error: %s: mail not sent"), _("RCPT TO response error: %s"),
get_smtp_error_string (error)); token);
g_free (respbuf);
return FALSE; return FALSE;
} }
} while (*(respbuf+3) == '-'); /* if we got "250-" then loop again */ } while (*(respbuf+3) == '-'); /* if we got "250-" then loop again */
@ -948,7 +994,7 @@ smtp_data (CamelSmtpTransport *transport, CamelMedium *message, gboolean has_8bi
/* if the message contains 8bit mime parts and the server /* if the message contains 8bit mime parts and the server
doesn't support it, encode 8bit parts to the best doesn't support it, encode 8bit parts to the best
encoding. This will also enforce an encoding to keep the lines in limit */ encoding. This will also enforce an encoding to keep the lines in limit */
if (has_8bit_parts && !CAMEL_TRANSPORT (transport)->supports_8bit) if (has_8bit_parts && !(transport->flags & CAMEL_SMTP_TRANSPORT_8BITMIME))
camel_mime_message_encode_8bit_parts (CAMEL_MIME_MESSAGE (message)); camel_mime_message_encode_8bit_parts (CAMEL_MIME_MESSAGE (message));
cmdbuf = g_strdup ("DATA\r\n"); cmdbuf = g_strdup ("DATA\r\n");
@ -972,13 +1018,21 @@ smtp_data (CamelSmtpTransport *transport, CamelMedium *message, gboolean has_8bi
/* we should have gotten instructions on how to use the DATA command: /* we should have gotten instructions on how to use the DATA command:
* 354 Enter mail, end with "." on a line by itself * 354 Enter mail, end with "." on a line by itself
*/ */
const char *token;
int error; int error;
if (!respbuf || !(transport->flags & CAMEL_SMTP_TRANSPORT_ENHANCEDSTATUSCODES)) {
error = respbuf ? atoi (respbuf) : 0; error = respbuf ? atoi (respbuf) : 0;
g_free (respbuf); token = get_smtp_error_string (error);
} else
token = respbuf + 4;
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("DATA response error: %s: mail not sent"), _("DATA response error: %s"),
get_smtp_error_string (error)); token);
g_free (respbuf);
return FALSE; return FALSE;
} }
@ -1049,14 +1103,21 @@ smtp_data (CamelSmtpTransport *transport, CamelMedium *message, gboolean has_8bi
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)")); d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
if (!respbuf || strncmp (respbuf, "250", 3)) { if (!respbuf || strncmp (respbuf, "250", 3)) {
const char *token;
int error; int error;
if (!respbuf || !(transport->flags & CAMEL_SMTP_TRANSPORT_ENHANCEDSTATUSCODES)) {
error = respbuf ? atoi (respbuf) : 0; error = respbuf ? atoi (respbuf) : 0;
g_free (respbuf); token = get_smtp_error_string (error);
} else
token = respbuf + 4;
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("DATA response error: message termination: " _("DATA termination response error: %s"),
"%s: mail not sent"), token);
get_smtp_error_string (error));
g_free (respbuf);
return FALSE; return FALSE;
} }
} while (*(respbuf+3) == '-'); /* if we got "250-" then loop again */ } while (*(respbuf+3) == '-'); /* if we got "250-" then loop again */
@ -1069,7 +1130,7 @@ static gboolean
smtp_rset (CamelSmtpTransport *transport, CamelException *ex) smtp_rset (CamelSmtpTransport *transport, CamelException *ex)
{ {
/* we are going to reset the smtp server (just to be nice) */ /* we are going to reset the smtp server (just to be nice) */
gchar *cmdbuf, *respbuf = NULL; char *cmdbuf, *respbuf = NULL;
cmdbuf = g_strdup ("RSET\r\n"); cmdbuf = g_strdup ("RSET\r\n");
@ -1092,13 +1153,21 @@ smtp_rset (CamelSmtpTransport *transport, CamelException *ex)
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)")); d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
if (!respbuf || strncmp (respbuf, "250", 3)) { if (!respbuf || strncmp (respbuf, "250", 3)) {
const char *token;
int error; int error;
if (!respbuf || !(transport->flags & CAMEL_SMTP_TRANSPORT_ENHANCEDSTATUSCODES)) {
error = respbuf ? atoi (respbuf) : 0; error = respbuf ? atoi (respbuf) : 0;
g_free (respbuf); token = get_smtp_error_string (error);
} else
token = respbuf + 4;
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("RSET response error: %s"), _("RSET response error: %s"),
get_smtp_error_string (error)); token);
g_free (respbuf);
return FALSE; return FALSE;
} }
} while (*(respbuf+3) == '-'); /* if we got "250-" then loop again */ } while (*(respbuf+3) == '-'); /* if we got "250-" then loop again */
@ -1111,7 +1180,7 @@ static gboolean
smtp_quit (CamelSmtpTransport *transport, CamelException *ex) smtp_quit (CamelSmtpTransport *transport, CamelException *ex)
{ {
/* we are going to reset the smtp server (just to be nice) */ /* we are going to reset the smtp server (just to be nice) */
gchar *cmdbuf, *respbuf = NULL; char *cmdbuf, *respbuf = NULL;
cmdbuf = g_strdup ("QUIT\r\n"); cmdbuf = g_strdup ("QUIT\r\n");
@ -1134,13 +1203,21 @@ smtp_quit (CamelSmtpTransport *transport, CamelException *ex)
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)")); d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
if (!respbuf || strncmp (respbuf, "221", 3)) { if (!respbuf || strncmp (respbuf, "221", 3)) {
const char *token;
int error; int error;
if (!respbuf || !(transport->flags & CAMEL_SMTP_TRANSPORT_ENHANCEDSTATUSCODES)) {
error = respbuf ? atoi (respbuf) : 0; error = respbuf ? atoi (respbuf) : 0;
g_free (respbuf); token = get_smtp_error_string (error);
} else
token = respbuf + 4;
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("QUIT response error: %s: non-fatal"), _("QUIT response error: %s"),
get_smtp_error_string (error)); token);
g_free (respbuf);
return FALSE; return FALSE;
} }
} while (*(respbuf+3) == '-'); /* if we got "221-" then loop again */ } while (*(respbuf+3) == '-'); /* if we got "221-" then loop again */

View File

@ -47,12 +47,18 @@ extern "C" {
#define CAMEL_IS_SMTP_TRANSPORT(o) (CAMEL_CHECK_TYPE((o), CAMEL_SMTP_TRANSPORT_TYPE)) #define CAMEL_IS_SMTP_TRANSPORT(o) (CAMEL_CHECK_TYPE((o), CAMEL_SMTP_TRANSPORT_TYPE))
#define CAMEL_SMTP_TRANSPORT_IS_ESMTP (1 << 0)
#define CAMEL_SMTP_TRANSPORT_8BITMIME (1 << 1)
#define CAMEL_SMTP_TRANSPORT_ENHANCEDSTATUSCODES (1 << 2)
#define CAMEL_SMTP_TRANSPORT_USE_SSL (1 << 3)
typedef struct { typedef struct {
CamelTransport parent_object; CamelTransport parent_object;
CamelStream *istream, *ostream; CamelStream *istream, *ostream;
gboolean use_ssl, is_esmtp; guint32 flags;
struct sockaddr_in localaddr; struct sockaddr_in localaddr;