diff options
author | Jeffrey Stedfast <fejj@helixcode.com> | 2000-10-03 07:26:53 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2000-10-03 07:26:53 +0800 |
commit | ed3681564ca93350b6c99e393376319a35abefde (patch) | |
tree | 911c88e6be6e7473e81c5ae2e435b47b6094777d /camel/providers | |
parent | 419c6ce7e3f3c42ebffe0b20b1529ef4cec93f9a (diff) | |
download | gsoc2013-evolution-ed3681564ca93350b6c99e393376319a35abefde.tar.gz gsoc2013-evolution-ed3681564ca93350b6c99e393376319a35abefde.tar.zst gsoc2013-evolution-ed3681564ca93350b6c99e393376319a35abefde.zip |
New convenience function to determine if there are any 8bit mime parts in
2000-10-02 Jeffrey Stedfast <fejj@helixcode.com>
* camel-mime-message.c (camel_mime_message_has_8bit_parts): New
convenience function to determine if there are any 8bit mime parts
in a mime message.
(camel_mime_message_encode_8bit_parts): New convenience function
to recursively reencode all 8bit mime parts to either
quoted-printable or base64 depending on which would be the best
encoding for that part.
* providers/smtp/camel-smtp-transport.c (smtp_data): If the mime
message contains 8bit parts and the server doesn't support 8bit
transfers, reencode those parts before proceding with the send.
(smtp_mail): If the mime message contains 8bit parts and the
server supports the 8BITMIME extension to SMTP, notify the server
that we'll be sending it 8bit mime parts.
(_send_to): Find out if the message contains 8bit parts.
svn path=/trunk/; revision=5677
Diffstat (limited to 'camel/providers')
-rw-r--r-- | camel/providers/smtp/camel-smtp-transport.c | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c index 02a0198f2f..2aae484c88 100644 --- a/camel/providers/smtp/camel-smtp-transport.c +++ b/camel/providers/smtp/camel-smtp-transport.c @@ -70,9 +70,11 @@ static void free_auth_types (CamelService *service, GList *authtypes); static char *get_name (CamelService *service, gboolean brief); static gboolean smtp_helo (CamelSmtpTransport *transport, CamelException *ex); -static gboolean smtp_mail (CamelSmtpTransport *transport, const char *sender, CamelException *ex); +static gboolean smtp_mail (CamelSmtpTransport *transport, const char *sender, + gboolean has_8bit_parts, CamelException *ex); static gboolean smtp_rcpt (CamelSmtpTransport *transport, const char *recipient, CamelException *ex); -static gboolean smtp_data (CamelSmtpTransport *transport, CamelMedium *message, CamelException *ex); +static gboolean smtp_data (CamelSmtpTransport *transport, CamelMedium *message, + gboolean has_8bit_parts, CamelException *ex); static gboolean smtp_rset (CamelSmtpTransport *transport, CamelException *ex); static gboolean smtp_quit (CamelSmtpTransport *transport, CamelException *ex); @@ -350,6 +352,7 @@ _send_to (CamelTransport *transport, CamelMedium *message, CamelInternetAddress *cia; char *recipient, *sender; const char *addr; + gboolean has_8bit_parts; GList *r; sender = g_strdup (camel_mime_message_get_from (CAMEL_MIME_MESSAGE (message))); @@ -371,7 +374,12 @@ _send_to (CamelTransport *transport, CamelMedium *message, return FALSE; } - smtp_mail (smtp_transport, addr, ex); + /* find out if the message has 8bit mime parts */ + has_8bit_parts = camel_mime_message_has_8bit_parts (CAMEL_MIME_MESSAGE (message)); + + /* rfc1652 (8BITMIME) requires that you notify the ESMTP daemon that + you'll be sending an 8bit mime message at "MAIL FROM:" time. */ + smtp_mail (smtp_transport, addr, has_8bit_parts, ex); if (!recipients) { camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, @@ -389,7 +397,10 @@ _send_to (CamelTransport *transport, CamelMedium *message, g_free (recipient); } - if (!smtp_data (smtp_transport, message, ex)) + /* passing in has_8bit_parts saves time as we don't have to + recurse through the message all over again if the user is + not sending 8bit mime parts */ + if (!smtp_data (smtp_transport, message, has_8bit_parts, ex)) return FALSE; /* reset the service for our next transfer session */ @@ -507,13 +518,16 @@ smtp_helo (CamelSmtpTransport *transport, CamelException *ex) } static gboolean -smtp_mail (CamelSmtpTransport *transport, const char *sender, 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) */ gchar *cmdbuf, *respbuf = NULL; /* enclose address in <>'s since some SMTP daemons *require* that */ - cmdbuf = g_strdup_printf ("MAIL FROM: <%s>\r\n", sender); + if (CAMEL_TRANSPORT (transport)->supports_8bit && has_8bit_parts) + cmdbuf = g_strdup_printf ("MAIL FROM: <%s> BODY=8BITMIME\r\n", sender); + else + cmdbuf = g_strdup_printf ("MAIL FROM: <%s>\r\n", sender); d(fprintf (stderr, "sending : %s", cmdbuf)); @@ -591,11 +605,8 @@ smtp_rcpt (CamelSmtpTransport *transport, const char *recipient, CamelException return TRUE; } -/* FIXME: if the message has 8bit mime parts and the server doesn't - support 8bit, we should re-encode those parts to either QP or - Base64 */ static gboolean -smtp_data (CamelSmtpTransport *transport, CamelMedium *message, CamelException *ex) +smtp_data (CamelSmtpTransport *transport, CamelMedium *message, gboolean has_8bit_parts, CamelException *ex) { /* now we can actually send what's important :p */ gchar *cmdbuf, *respbuf = NULL; @@ -603,7 +614,13 @@ smtp_data (CamelSmtpTransport *transport, CamelMedium *message, CamelException * CamelMimeFilter *crlffilter, *lwfilter; gint crlfid, lwid; - /* enclose address in <>'s since some SMTP daemons *require* that */ + + /* if the message contains 8bit mime parts and the server + doesn't support it, encode 8bit parts to the best + encoding. */ + if (has_8bit_parts && !CAMEL_TRANSPORT (transport)->supports_8bit) + camel_mime_message_encode_8bit_parts (CAMEL_MIME_MESSAGE (message)); + cmdbuf = g_strdup ("DATA\r\n"); d(fprintf (stderr, "sending : %s", cmdbuf)); |