Hi Steve, Thanks for the detailed explanation regarding the clarification sought. I really appreciate it.
My current requirement dictates that I be able to send a mail with a provisional message body and with a file attachment using libcurl over TLS. I humbly feel your example would more than suffice. I shall work on my solution on similar lines at least for a start. Thanks again.. :) Thanks, Naveen -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Steve Holme Sent: Monday, April 02, 2012 3:55 PM To: 'libcurl development' Subject: RE: MIME library to use with curl SMTP Hi Naveen, > Kindly suggest a suitable/compatible open source MIME > library to use for attaching files when using curl's SMTP > client for sending mails using TLS. I don't know of any MIME libraries that will do this for you but I have written my own email generation (for using with libcurl's SMTP) and email parsing (when receiving emails via libcurl's POP3) and it is relevantly easy to do this yourself. You will need a base64 encoding function and a quoted-printable encoding function (if you want to encode your text content). Typically the SMTP message consists of a set of headers, a blank line and a body. Libcurl adds the necessary EOB terminator that is required by the server to terminate the message so you don't need to add that. Your header will need to: * Set the Content-Type to multipart/mixed making sure to include a boundary specifier. I use a 16 random character base64 string. * Set the Mime-Version header to 1.0. The body of the message will then include: * Optional pre-amble text - which might be "This is a multi-part message in MIME format.". * A number of sub-messages. One for the actual email content and one for each file attachment. Each sub-message will have their own header, blank line separator and body. Typically Content-Type and Content-Transfer-Encoding are included for the email content and Content-Type, Content-Transfer-Encoding, Content-Description and Content-Disposition for file attachments. See my example at the end of this email for details. * An optional epilogue - which I don't include. If you want to include plain text and html text (and/or rich text) alternative context then things get a little more complicated. If you want to include inline images in your html text then again, things are even more complicated but I can talk you through these if you need to do this. Kind Regards Steve From: [email protected] To: [email protected] Subject: Test Message Date: Mon, 02 Apr 2012 11:00:00 +0100 Content-Type: multipart/mixed; boundary="pj+EhsWuSQJxx7pr" Mime-version: 1.0 This is a multi-part message in MIME format. --pj+EhsWuSQJxx7pr Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello --pj+EhsWuSQJxx7pr Content-Type: application/octet-stream; name="Test.txt" Content-Transfer-Encoding: base64 Content-Description: Test.txt Content-Disposition: attachment; filename="Test.txt"; size=400; creation-date="Mon, 02 Apr 2012 10:00:00 GMT"; modification-date="Mon, 02 Apr 2012 10:00:00 GMT" [base64 encoding text split across multiple lines, each being 76 characters long] --pj+EhsWuSQJxx7pr-- ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.html ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.html
