muquit / mailsend

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

cannot have body and attachment, in 1.20b #127

Open ArtZL opened 6 years ago

ArtZL commented 6 years ago

MailSend v 1.20b Windows 10

Does not work with having both -msg-body and -attach. I thought 1.20b was to fix this. This is a rather critical feature!

mailsend -v -f support@mysite.com -smtp smtp.mysite.com -port 587 -t someone@somewhere.com -sub "This is the Subject" -name "from Art" -rt support@mysite.com -auth -user support@mysite.com -pass mypwd -msg-body body.txt -attach "test.pdf"

Is there a fix for this?

nickbe commented 6 years ago

Sending an attachment without mail body seems completely useless to me. Why does no one care to fix this? Is the project dead? Have the original programmers abandoned it?

muquit commented 6 years ago

First of all, the option -msg-body and -attach will never work together.

Let's explain why.

The -attach option creates properly formatted MIME mail by separating the attachments with boundary. Example:

--azLHFNyN32YCQGCU
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

This is a test

--azLHFNyN32YCQGCU
Content-Type: text/plain; charset=utf-8
Content-Disposition: attachment; filename="msg_body_utf8.txt"
Content-Transfer-Encoding: 8bit

中文測試
--azLHFNyN32YCQGCU--

The -msg-body option "includes" the file without any MIME boundary, kind of like old school mail. Therefore, -attach and -msg-body can not be mixed. Note: character set can be specified with option -cs if the message file is in utf-8 for example and mailsend will add Content-Type header for MIME capable mail reader. Use -msg-body only if you only want to include one file as body of the message.

Everybody wants to use -msg-body because body always show up in mail and any mailer can display it. Please look at FAQ# 1 on how to use inline content disposition of attachment so that it will show up as "message body" and any decent mail reader will display it as body.

And all these frustations are because of the broken behavior of Outlook. In FAQ, I noticed the link to Microsoft kb article is broken at this time.

Thanks.

nickbe commented 6 years ago

I just figured that one out couple of hours before. Now I have two or more attachments, one as 'inline' with the real message body formatted as html - not encoded, and the others are the attachments as 'attached' and base64 encoded.

I think what's really missing here is a bunch of real world examples. And sending a well formatted html mail with an image below the signature together with several different types of attachments like two PDFs and one DOC is probably as real as it gets.

At least it's what I was trying to achieve in the first place.

So I'd humbly ask that you extend the wiki a little bit and give us one or two full blown examples with everything from custom mail header fields to different attachments. 😀

btw, A colleague of mine just mentioned that he gave up on mailsend not so long ago because he coulnd't figure out what I did today. Makes me grin happily, but also think that maybe mailsend could be much more recognized for what it is: The most complete commandline mailer for windows.

ArtZL commented 6 years ago

I finally figured it out after a lot of trial-and-error. The order of the parameters is important.

-disposition attachment -attach "attachment.jpg" -disposition inline -attach "body.txt"