summaryrefslogtreecommitdiff
path: root/camel/providers/smtp
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2004-03-12 22:36:06 +0000
committerJeffrey Stedfast <fejj@src.gnome.org>2004-03-12 22:36:06 +0000
commit6b35f6c3f1096b44d417136de8db3ec4704798d9 (patch)
treebf999c85befe8327c8ee5f528a3d18cf0ee2a150 /camel/providers/smtp
parent25a32129e82e41fd3e9b9251744df98700d9a4bb (diff)
downloadevolution-data-server-6b35f6c3f1096b44d417136de8db3ec4704798d9.tar.gz
Fix for bug #53497.
2004-03-12 Jeffrey Stedfast <fejj@ximian.com> Fix for bug #53497. * providers/smtp/camel-smtp-transport.c (smtp_helo): Instead of unreffing the streams, call camel_service_disconnect(). (smtp_mail): Same. (smtp_rcpt): Same. (smtp_data): Same. (smtp_send_to): Ignore exceptions for smtp_rset(). Also, check that we are connected before we try to send (in Evolution's current usage scenario, this isn't a problem but in the future if we ever try to fire off several messages via the same smtp connection, it may be - especially if RSET failed during the previous send).
Diffstat (limited to 'camel/providers/smtp')
-rw-r--r--camel/providers/smtp/camel-smtp-transport.c56
1 files changed, 19 insertions, 37 deletions
diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c
index 429b24e37..35b7e858d 100644
--- a/camel/providers/smtp/camel-smtp-transport.c
+++ b/camel/providers/smtp/camel-smtp-transport.c
@@ -681,6 +681,12 @@ smtp_send_to (CamelTransport *transport, CamelMimeMessage *message,
const char *addr;
int i, len;
+ if (!smtp_transport->connected) {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_NOT_CONNECTED,
+ _("Cannot send message: service not connected."));
+ return FALSE;
+ }
+
if (!camel_internet_address_get (CAMEL_INTERNET_ADDRESS (from), 0, NULL, &addr)) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot send message: sender address not valid."));
@@ -710,14 +716,14 @@ smtp_send_to (CamelTransport *transport, CamelMimeMessage *message,
cia = CAMEL_INTERNET_ADDRESS (recipients);
for (i = 0; i < len; i++) {
char *enc;
-
+
if (!camel_internet_address_get (cia, i, NULL, &addr)) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot send message: one or more invalid recipients"));
camel_operation_end (NULL);
return FALSE;
}
-
+
enc = camel_internet_address_encode_address(NULL, NULL, addr);
if (!smtp_rcpt (smtp_transport, enc, ex)) {
g_free(enc);
@@ -733,7 +739,8 @@ smtp_send_to (CamelTransport *transport, CamelMimeMessage *message,
}
/* reset the service for our next transfer session */
- smtp_rset (smtp_transport, ex);
+ if (!smtp_rset (smtp_transport, ex))
+ camel_exception_clear (ex);
camel_operation_end (NULL);
@@ -855,7 +862,7 @@ smtp_set_exception (CamelSmtpTransport *transport, const char *respbuf, const ch
if (!respbuf) {
/* we got disconnected */
- transport->connected = FALSE;
+ camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
}
}
@@ -933,11 +940,7 @@ smtp_helo (CamelSmtpTransport *transport, CamelException *ex)
_("HELO command failed: %s"), g_strerror (errno));
camel_operation_end (NULL);
- transport->connected = FALSE;
- camel_object_unref (transport->istream);
- transport->istream = NULL;
- camel_object_unref (transport->ostream);
- transport->ostream = NULL;
+ camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
return FALSE;
}
@@ -1147,10 +1150,7 @@ smtp_mail (CamelSmtpTransport *transport, const char *sender, gboolean has_8bit_
_("MAIL FROM command failed: %s: mail not sent"),
g_strerror (errno));
- camel_object_unref (transport->istream);
- transport->istream = NULL;
- camel_object_unref (transport->ostream);
- transport->ostream = NULL;
+ camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
return FALSE;
}
@@ -1191,10 +1191,7 @@ smtp_rcpt (CamelSmtpTransport *transport, const char *recipient, CamelException
_("RCPT TO command failed: %s: mail not sent"),
g_strerror (errno));
- camel_object_unref (transport->istream);
- transport->istream = NULL;
- camel_object_unref (transport->ostream);
- transport->ostream = NULL;
+ camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
return FALSE;
}
@@ -1252,10 +1249,7 @@ smtp_data (CamelSmtpTransport *transport, CamelMimeMessage *message, CamelExcept
_("DATA command failed: %s: mail not sent"),
g_strerror (errno));
- camel_object_unref (transport->istream);
- transport->istream = NULL;
- camel_object_unref (transport->ostream);
- transport->ostream = NULL;
+ camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
return FALSE;
}
@@ -1315,10 +1309,7 @@ smtp_data (CamelSmtpTransport *transport, CamelMimeMessage *message, CamelExcept
camel_object_unref (filtered_stream);
- camel_object_unref (transport->istream);
- transport->istream = NULL;
- camel_object_unref (transport->ostream);
- transport->ostream = NULL;
+ camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
return FALSE;
}
@@ -1335,10 +1326,7 @@ smtp_data (CamelSmtpTransport *transport, CamelMimeMessage *message, CamelExcept
_("DATA command failed: %s: mail not sent"),
g_strerror (errno));
- camel_object_unref (transport->istream);
- transport->istream = NULL;
- camel_object_unref (transport->ostream);
- transport->ostream = NULL;
+ camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
return FALSE;
}
@@ -1376,10 +1364,7 @@ smtp_rset (CamelSmtpTransport *transport, CamelException *ex)
camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
_("RSET command failed: %s"), g_strerror (errno));
- camel_object_unref (transport->istream);
- transport->istream = NULL;
- camel_object_unref (transport->ostream);
- transport->ostream = NULL;
+ camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
return FALSE;
}
@@ -1418,10 +1403,7 @@ smtp_quit (CamelSmtpTransport *transport, CamelException *ex)
camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
_("QUIT command failed: %s"), g_strerror (errno));
- camel_object_unref (transport->istream);
- transport->istream = NULL;
- camel_object_unref (transport->ostream);
- transport->ostream = NULL;
+ camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
return FALSE;
}