muquit / mailsend

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

Set mime-type not present in raw email headers #128

Open luicir opened 6 years ago

luicir commented 6 years ago

When I set mime-type, I get the header "content-type" instead filled with its value. e,g: mailsend -smtp local-mail.com -f sender@sender.local -t receiver@receiver.local m -sub "Another Test Email With HTML body and mime type set from file body" -mime-type "text/html" -msg-body ~/justbody.html -starttls -user xxx -pass xxx

My SMPT ingestor will get the following with no signs of mime-type

Received: from localhost (unknown [10.91.142.1]) by local-mail.dev.com (Postfix) with ESMTPS for receiver@receiver.local; Wed, 31 Jan 2018 11:37:10 +0000 (UTC) Subject: Another Test Email With HTML body and mime type set from file body From: sender@sender.local Date: Wed, 31 Jan 2018 11:37:10 +0000 To: receiver@receiver.local X-Mailer: @(#) mailsend v1.19 (Unix) X-Copyright: BSD. It is illegal to use this software for Spamming Mime-version: 1.0 Content-Type: text/html; charset=utf-8

This is a test for mime tipe set to html from an HTML file body

if I add both content-type and mime-type, the result is the same and content type is discarded. eg:

mailsend -smtp local-mail.com -f sender@sender.local -t receiver@receiver.local m -sub "Another Test Email With HTML body and mime type set from file body" -mime-type "text/html" -content-type "multipart/mixed" -msg-body ~/justbody.html -starttls -user xxx -pass xxx

How can I set mime-type header with mailsend? What is the difference between mime-type and content-type parameters in mailsend?

tripleee commented 6 years ago

For background, see https://stackoverflow.com/questions/48541804/mime-type-missing-in-mailsend-email-client

tripleee commented 6 years ago

Your example shows "Content-Type: text/html", which differs from what you posted on Stack Overflow, and conflicts with the assertion "no sign of text-html [sic]". Did you transcribe the problem incorrectly?

luicir commented 6 years ago

In stack overflow I first had the issue that neither content-type or mime-type showed if the param was after the message body. When I realized that, I changed the subject of this thread and closed the issue on stackoverflow. I can maybe refrase the issue like this: how can I set mime-type in email headers with mailsend? Or: what is the difference between option mime-type and option content-type?

muquit commented 6 years ago

To see the list of mime types, type mailsend -show-mime-types. To sepecify a MIME type use the option -mime-type before every -attach option (order matters). Please look at FAQ How to embed images in HTML? to see how the option -content-type is used.

Thanks

luicir commented 6 years ago

I have no attachment whatsoever, and the mime type "text/plain" or "text/html" is a valid mime type for the email itself. So, is the purpose of mime-type parameter only for attachments? Documentation doesn't say that

muquit commented 6 years ago

Please note -msg-body is a hack, it just includes the file in the body of the message without any MIME boundary string. It is not a proper MIME mail. Also this option does not mix with -attach option.

If you want proper MIME mail, use -attach. If you are trying to see the HTML as message body and it is not working, please look at the FAQ-1

Custom headers can be added with -H option but SMTP server may strip them off if it decides to do so.

Thanks.

luicir commented 6 years ago

Asides the way I attach the body, what I am expecting is a difference between setting the mime-type and setting the content-type (something like including a "mime-type" header instead of "content-type": is this the standard?). In fact if I send a one line message, without a body attached, and try setting the mime-type, and have this result: command:

mailsend -smtp local-mail.proofpointessentialsarchive.com -f sender@sender.local -t receiver.local -sub "test for mime-type header" -mime-type "text/plain" -content-type "multipart/mixed" -starttls -user xxx -pass xxx -M "this is a test for mime-type header" Result:

Received: from localhost (localhost)
    by local-mail.dev (Postfix) with ESMTPS
    for <receiver.local>; Thu,  1 Feb 2018 07:42:16 +0000 (UTC)
Subject: test for mime-type header
From: sender@sender.local
Date: Thu, 01 Feb 2018 07:42:16 +0000
To: receiver.local
X-Mailer: @(#) mailsend v1.19 (Unix)
X-Copyright: BSD. It is illegal to use this software for Spamming
Mime-version: 1.0
Content-type: multipart/mixed; boundary="M6zEeJl1QPoIhMVQ"

--M6zEeJl1QPoIhMVQ
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline

this is a test for mime-type header
--M6zEeJl1QPoIhMVQ--

where mime-type is content-type header for the message and not the email, that becomes multipart mixed. I'm confused, probably missing something.

muquit commented 6 years ago

Yes there is no such thing as mime-type in mail header, it is Content-Type. mime-type is used to construct the type, character set, encoding etc. of the attachments in mail body (Content-Type, Content-Disposition etc seen in mail body).

Thanks

luicir commented 6 years ago

So the parameter mime-type is meaningless when attachments are not present?