curl / Mailing Lists / curl-library / Single Mail

curl-library

smtp: support for RFC 6152 (8BITMIME)

From: Deweloper <deweloper_at_wp.pl>
Date: Thu, 16 Mar 2017 23:43:43 +0100

Hi,

What do you think about adding support for 8BITMIME extension to curl's SMTP client, as defined in https://tools.ietf.org/html/rfc6152 ?

Please have a look at the patch below.
Probably there should be a way to tell curl that the content we're going to sent actually needs the 8th bit to be preserved. In such case curl should fail when 8BITMIME capability is not supported by the server. A new URL option, maybe?

diff -urw curl-7.53.1~/lib/smtp.c curl-7.53.1/lib/smtp.c
--- curl-7.53.1~/lib/smtp.c 2017-02-21 08:09:13.000000000 +0100
+++ curl-7.53.1/lib/smtp.c 2017-03-16 23:37:47.616272595 +0100
@@ -550,6 +550,7 @@
   char *from = NULL;
   char *auth = NULL;
   char *size = NULL;
+ const char *body = "";
   CURLcode result = CURLE_OK;
   struct Curl_easy *data = conn->data;
 
@@ -592,19 +593,24 @@
     }
   }
 
+ /* Calculate the optional BODY parameter */
+ if(conn->proto.smtpc.eightbitmime_supported) {
+ body = " BODY=8BITMIME";
+ }
+
   /* Send the MAIL command */
   if(!auth && !size)
     result = Curl_pp_sendf(&conn->proto.smtpc.pp,
- "MAIL FROM:%s", from);
+ "MAIL FROM:%s%s", from, body);
   else if(auth && !size)
     result = Curl_pp_sendf(&conn->proto.smtpc.pp,
- "MAIL FROM:%s AUTH=%s", from, auth);
+ "MAIL FROM:%s AUTH=%s%s", from, auth, body);
   else if(auth && size)
     result = Curl_pp_sendf(&conn->proto.smtpc.pp,
- "MAIL FROM:%s AUTH=%s SIZE=%s", from, auth, size);
+ "MAIL FROM:%s AUTH=%s SIZE=%s%s", from, auth, size, body);
   else
     result = Curl_pp_sendf(&conn->proto.smtpc.pp,
- "MAIL FROM:%s SIZE=%s", from, size);
+ "MAIL FROM:%s SIZE=%s%s", from, size, body);
 
   free(from);
   free(auth);
@@ -738,6 +744,10 @@
     else if(len >= 4 && !memcmp(line, "SIZE", 4))
       smtpc->size_supported = TRUE;
 
+ /* Does the server support the 8BITMIME capability? */
+ else if(len >= 4 && !memcmp(line, "8BITMIME", 4))
+ smtpc->eightbitmime_supported = TRUE;
+
     /* Does the server support authentication? */
     else if(len >= 5 && !memcmp(line, "AUTH ", 5)) {
       smtpc->auth_supported = TRUE;
diff -urw curl-7.53.1~/lib/smtp.h curl-7.53.1/lib/smtp.h
--- curl-7.53.1~/lib/smtp.h 2016-11-07 10:18:18.000000000 +0100
+++ curl-7.53.1/lib/smtp.h 2017-03-16 23:37:10.423919368 +0100
@@ -72,6 +72,7 @@
   bool size_supported; /* If server supports SIZE extension according to
                               RFC 1870 */
   bool auth_supported; /* AUTH capability supported by server */
+ bool eightbitmime_supported; /* 8BITMIME capability (RFC 6152) supported by server */
 };
 
 extern const struct Curl_handler Curl_handler_smtp;

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2017-03-16