muquit / mailsend

A program to send mail via SMTP from command line
Other
297 stars 68 forks source link

missing crlf before boundary separator #108

Closed 0x3b0c closed 7 years ago

0x3b0c commented 7 years ago

In multipart mail a CRLF is missing before the boundary separator, this is causing different problems in many email clients / webmail. (Some are reporting empty mails other missing attachments).

example:

Content-type: multipart/mixed; boundary="sijiO+FfxL/LbC3K"
--sijiO+FfxL/LbC3K
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: base64

Base64StringBase64StringBase64StringBase64StringBase64StringBase64StringBase64StringBase64StringBase64StringBase64String===
--sijiO+FfxL/LbC3K
Content-Type: application/pdf; charset=utf-8
Content-Disposition: attachment; filename="TEST.PDF"
Content-Transfer-Encoding: base64

it should be:

Content-type: multipart/mixed; boundary="sijiO+FfxL/LbC3K"

--sijiO+FfxL/LbC3K
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: base64

Base64StringBase64StringBase64StringBase64StringBase64StringBase64StringBase64StringBase64StringBase64StringBase64String===

--sijiO+FfxL/LbC3K
Content-Type: application/pdf; charset=utf-8
Content-Disposition: attachment; filename="TEST.PDF"
Content-Transfer-Encoding: base64
muquit commented 7 years ago

sorry not getting time. will look at it as soon as get some time.

kidmar commented 7 years ago

I've got the same problem too with attachments. I think the problem can be solved editing file smtp.c and replacing: snprintf(buf, bufsz,"-- (or something similar that prints -- at the beginning of a line with snprintf(buf, bufsz,"\r\n--

This should be done whenever there is a snprintf immediatly followed by an snprintf that writes a Content-Type (about 5-6 times). I would like to try and test it but I just can't compile mailsend because it takes me too much time to setup the environment

muquit commented 7 years ago

Although I could not reproduce the original issue with gmail, I updated develop branch with the code as you suggested which also works with gmail. If possible, please test it with your SMTP server to see if the issue is fixed.

Thanks.