muquit / mailsend

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

Send Calendar attachment fails #118

Open f-steff opened 6 years ago

f-steff commented 6 years ago

I started testing this with 1.19, but found multiple attach with individual enc-types was broken. Continued with 1.20b, which works where 1.19 didn't.

I'm attempting to replicate the way Outlook sends a meeting invitation. These messages contains three parts: text, html and an iCalendar entry. The relevant part of the received message looks like this:

Content-Type: multipart/alternative; boundary="_000_BN6PR1001MB2244A082AECBEA4A97C792B4E8690BN6PR1001MB2244_"

--_000_BN6PR1001MB2244A082AECBEA4A97C792B4E8690BN6PR1001MB2244_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

cut text

--_000_BN6PR1001MB2244A082AECBEA4A97C792B4E8690BN6PR1001MB2244_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

cut html

--_000_BN6PR1001MB2244A082AECBEA4A97C792B4E8690BN6PR1001MB2244_
Content-Type: text/calendar; charset="utf-8"; method=REQUEST
Content-Transfer-Encoding: base64

cut Base64

--_000_BN6PR1001MB2244A082AECBEA4A97C792B4E8690BN6PR1001MB2244_--

I'm using this batch file to create and send the message:

mailsend1.20b.exe -smtp secret.smtp.net -port 25 ^
                 -v ^
                 -show-attach ^
                 -f mymail@myself.com -v ^
                 -list_address Recipients.txt ^
                 -sub "TestSubject %TIME%" ^
                 -content-type "multipart/alternative" ^
                 ^
                 -enc-type "quoted-printable" ^
                 -cs "iso-8859-1" ^
                 -disposition "inline" ^
                 -mime-type "text/plain" ^
                 -attach ".\MailBody.txt" ^
                 ^
                 -enc-type "quoted-printable" ^
                 -cs "iso-8859-1" ^
                 -disposition "inline" ^
                 -mime-type "text/html" ^
                 -attach ".\MailBody.html" ^
                 ^
                 -enc-type "base64" ^
                 -cs "utf-8" ^
                 -disposition "inline" ^
                 -mime-type "text/calandar" ^
                 -attach ".\Maintenance.vcf" ^
                 -log mailsend.log

I've tried lots of setups, but I can't replicate the output from Outlook. Here are three attempts that illustrate my problems:

1.

This includes both these lines in the mailsend call: -content-type "multipart/alternative" -disposition "inline"

The result is the html file visible when received in gmail - everything else is hidden.

Content-Type: multipart/alternative; boundary="CYjOYKy2hpqRM1b6"

--CYjOYKy2hpqRM1b6
Content-Type: text/plain; charset="iso-8859-1"
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Cut text

--CYjOYKy2hpqRM1b6
Content-Type: text/html; charset="iso-8859-1"
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

cut html

--CYjOYKy2hpqRM1b6
Content-Type: text/calandar; charset="utf-8"
Content-Disposition: inline
Content-Transfer-Encoding: base64

Cut base64

--CYjOYKy2hpqRM1b6--

2.

This one includes only this line in the mailsend call: -content-type "multipart/alternative"

The result is an empty body with four!!! attachments (txt, html, vcf,html) when received in gmail - although the mail contents look differently:

Content-Type: multipart/alternative; boundary="CrEpabQ4ZeFcibBK"

--CrEpabQ4ZeFcibBK
Content-Type: text/plain; charset="iso-8859-1"; name="MailBody.txt"
Content-Disposition: attachment; filename="MailBody.txt"
Content-Transfer-Encoding: quoted-printable
Content-Description: MailBody.txt

Cut Text

--CrEpabQ4ZeFcibBK
Content-Type: text/html; charset="iso-8859-1"; name="MailBody.html"
Content-Disposition: attachment; filename="MailBody.html"
Content-Transfer-Encoding: quoted-printable
Content-Description: MailBody.html

Cut html

--CrEpabQ4ZeFcibBK
Content-Type: text/calandar; charset="utf-8"; name="Maintenance.vcf"
Content-Disposition: attachment; filename="Maintenance.vcf"
Content-Transfer-Encoding: base64
Content-Description: Maintenance.vcf

Cut base64
--CrEpabQ4ZeFcibBK--

3.

This does not include any of these lines in the mailsend call: -content-type "multipart/alternative" -disposition "inline"

The result is an empty body with three attachments when received in gmail:

Content-Type: multipart/mixed; boundary="qsKyhPAprgCNKo9g"

--qsKyhPAprgCNKo9g
Content-Type: text/plain; charset="iso-8859-1"; name="MailBody.txt"
Content-Disposition: attachment; filename="MailBody.txt"
Content-Transfer-Encoding: quoted-printable
Content-Description: MailBody.txt

Cut text

--qsKyhPAprgCNKo9g
Content-Type: text/html; charset="iso-8859-1"; name="MailBody.html"
Content-Disposition: attachment; filename="MailBody.html"
Content-Transfer-Encoding: quoted-printable
Content-Description: MailBody.html

Cut html

--qsKyhPAprgCNKo9g
Content-Type: text/calandar; charset="utf-8"; name="Maintenance.vcf"
Content-Disposition: attachment; filename="Maintenance.vcf"
Content-Transfer-Encoding: base64
Content-Description: Maintenance.vcf

Cut base64

--qsKyhPAprgCNKo9g--

How can I do this? Is it even possible?

In fact, I know exactly how the message contents should be, so I was wondering if you would consider adding a way to specify the message contents as a raw text file?

And since I've been sending a lot of emails today to try to get this to work, I was also considering if you could add a -SaveTemporalyFileHereAndExit FilePath switch, which would be very handy for debugging message contents.

muquit commented 6 years ago

Thanks for the report, will look at it as soon as get some time.