diff options
Diffstat (limited to 'camel/providers/smtp/camel-smtp-transport.c')
-rw-r--r-- | camel/providers/smtp/camel-smtp-transport.c | 74 |
1 files changed, 42 insertions, 32 deletions
diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c index c54e0821d8..78509fad28 100644 --- a/camel/providers/smtp/camel-smtp-transport.c +++ b/camel/providers/smtp/camel-smtp-transport.c @@ -69,8 +69,7 @@ /* camel smtp transport class prototypes */ static gboolean smtp_can_send (CamelTransport *transport, CamelMedium *message); static gboolean smtp_send (CamelTransport *transport, CamelMedium *message, CamelException *ex); -static gboolean smtp_send_to (CamelTransport *transport, CamelMedium *message, - CamelAddress *from, CamelAddress *recipients, CamelException *ex); +static gboolean smtp_send_to (CamelTransport *transport, CamelMedium *message, GList *recipients, CamelException *ex); /* support prototypes */ static void smtp_construct (CamelService *service, CamelSession *session, @@ -567,23 +566,24 @@ smtp_can_send (CamelTransport *transport, CamelMedium *message) static gboolean smtp_send_to (CamelTransport *transport, CamelMedium *message, - CamelAddress *from, CamelAddress *recipients, - CamelException *ex) + GList *recipients, CamelException *ex) { CamelSmtpTransport *smtp_transport = CAMEL_SMTP_TRANSPORT (transport); const CamelInternetAddress *cia; - gboolean has_8bit_parts; + char *recipient; const char *addr; - int i, len; + gboolean has_8bit_parts; + GList *r; - if (!from) { + cia = camel_mime_message_get_from (CAMEL_MIME_MESSAGE (message)); + if (!cia) { camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot send message: " "sender address not defined.")); return FALSE; } - if (!camel_internet_address_get (CAMEL_INTERNET_ADDRESS (from), 0, NULL, &addr)) { + if (!camel_internet_address_get (cia, 0, NULL, &addr)) { camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot send message: " "sender address not valid.")); @@ -603,24 +603,18 @@ smtp_send_to (CamelTransport *transport, CamelMedium *message, camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot send message: " "no recipients defined.")); - camel_operation_end (NULL); + camel_operation_end(NULL); return FALSE; } - len = camel_address_length (recipients); - cia = CAMEL_INTERNET_ADDRESS (recipients); - for (i = 0; i < len; i++) { - 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; - } - - if (!smtp_rcpt (smtp_transport, addr, ex)) { + for (r = recipients; r; r = r->next) { + recipient = (char *) r->data; + if (!smtp_rcpt (smtp_transport, recipient, ex)) { + g_free (recipient); camel_operation_end (NULL); return FALSE; } + g_free (recipient); } /* passing in has_8bit_parts saves time as we don't have to @@ -642,26 +636,42 @@ smtp_send_to (CamelTransport *transport, CamelMedium *message, static gboolean smtp_send (CamelTransport *transport, CamelMedium *message, CamelException *ex) { - const CamelInternetAddress *from, *to, *cc, *bcc; - CamelInternetAddress *recipients = NULL; - gboolean status; - - from = camel_mime_message_get_from (CAMEL_MIME_MESSAGE (message)); + const CamelInternetAddress *to, *cc, *bcc; + GList *recipients = NULL; + guint index, len; to = camel_mime_message_get_recipients (CAMEL_MIME_MESSAGE (message), CAMEL_RECIPIENT_TYPE_TO); cc = camel_mime_message_get_recipients (CAMEL_MIME_MESSAGE (message), CAMEL_RECIPIENT_TYPE_CC); bcc = camel_mime_message_get_recipients (CAMEL_MIME_MESSAGE (message), CAMEL_RECIPIENT_TYPE_BCC); - recipients = camel_internet_address_new (); - camel_address_cat (CAMEL_ADDRESS (recipients), CAMEL_ADDRESS (to)); - camel_address_cat (CAMEL_ADDRESS (recipients), CAMEL_ADDRESS (cc)); - camel_address_cat (CAMEL_ADDRESS (recipients), CAMEL_ADDRESS (bcc)); + /* get all of the To addresses into our recipient list */ + len = camel_address_length (CAMEL_ADDRESS (to)); + for (index = 0; index < len; index++) { + const char *addr; + + if (camel_internet_address_get (to, index, NULL, &addr)) + recipients = g_list_append (recipients, g_strdup (addr)); + } - status = smtp_send_to (transport, message, CAMEL_ADDRESS (from), CAMEL_ADDRESS (recipients), ex); + /* get all of the Cc addresses into our recipient list */ + len = camel_address_length (CAMEL_ADDRESS (cc)); + for (index = 0; index < len; index++) { + const char *addr; + + if (camel_internet_address_get (cc, index, NULL, &addr)) + recipients = g_list_append (recipients, g_strdup (addr)); + } - camel_object_unref (CAMEL_OBJECT (recipients)); + /* get all of the Bcc addresses into our recipient list */ + len = camel_address_length (CAMEL_ADDRESS (bcc)); + for (index = 0; index < len; index++) { + const char *addr; + + if (camel_internet_address_get (bcc, index, NULL, &addr)) + recipients = g_list_append (recipients, g_strdup (addr)); + } - return status; + return smtp_send_to (transport, message, recipients, ex); } static gboolean |