muquit / mailsend-go

mailsend-go is a multi-platform command line tool to send mail via SMTP protocol
Other
166 stars 16 forks source link

Behaviour with charsets and attachments #29

Open marpagu opened 4 years ago

marpagu commented 4 years ago

Hi, First of all, I would like to thank your work regarding mailsend-go. I was using mailsend in the past but, as you recommend, I am considering to move to mailsend-go. I am writing to you as I am getting some problems regarding charsets and attachments (using current version 1.0.9). To sum up, my need is to send emails with a body that is a html file and, optionally, attach some documents (let's say pdf files). Furthermore, I need to use "ISO-8859-1" charset.

1) My first problem is with the charset. I use words that contain accent vowels so, for testing, I use the same text both in subject and body: "Número de documento: ". I have tried different options and I got these results (an image is attached) :

The subject is not well managed regarding charset. This is the text showed in the subject: "Número de documento: TEST/20-000001".

Using body param with a html file mailsend-go.exe -t RECEIVER@mail.com -smtp smtp.office365.com -port 587 -f SENDER@mail.com -sub "Número de documento: TEST/20-000001" auth -user SENDER@mail.com -pass PASSWORD -cs "ISO-8859-1" body -file "C:/simple.html" -mime-type text/html

Using attach param with a html file inline. mailsend-go.exe -t RECEIVER@mail.com -smtp smtp.office365.com -port 587 -f SENDER@mail.com -sub "Número de documento: TEST/20-000001" auth -user SENDER@mail.com -pass PASSWORD -cs "ISO-8859-1" attach -file "C:/simple.html" -mime-type text/html -inline

Using body -msg param. mailsend-go.exe -t RECEIVER@mail.com -smtp smtp.office365.com -port 587 -f SENDER@mail.com -sub "Número de documento: TEST/20-000001" auth -user SENDER@mail.com -pass PASSWORD -cs "ISO-8859-1" body -msg "Número de documento: TEST/20-0000001"

2) My second problem is with attachments in a specific case: using at the same time a html file WITH inline and a pdf file WITHOUT inline. In this case, both file are included in the email as inline. The expected output would be that the pdf file was included as an attachment in the email. Here is the command I am using: mailsend-go.exe -t RECEIVER@mail.com -smtp smtp.office365.com -port 587 -f SENDER@mail.com -sub "Número de documento: TEST/20-000001" auth -user SENDER@mail.com -pass PASSWORD -cs "ISO-8859-1" attach -file "C:/simple.html" -mime-type text/html -inline attach -file "C:/a.pdf" -mime-type application/pdf

The html file (simple.html but uploaded with txt extension) is attached in case you want it to test:

Again, thank you for your effort and kind regards, Marcos Palacios

MailsendGo - Charset and attachments

simple.txt

marpagu commented 4 years ago

In addition to this, I have tried to use "UTF-8" and, in this case, subject is properly showed but the body of the email (the html file) does not manage well the accent vowels:

mailsend-go.exe -t RECEIVER@mail.com -smtp smtp.office365.com -port 587 -f SENDER@mail.com -sub "Número de documento: TEST/20-000001" auth -user SENDER@mail.com -pass PASSWORD -cs "UTF-8" body -file "C:/simple.html" -mime-type text/html

UTF8 subject and body

gaebor commented 4 years ago

Just a hunch, maybe your command line input is incorrect. Did you change the command line character table? See this: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/chcp

marpagu commented 4 years ago

I have already reviewed it and my current active code page is 850 (Multilingual). I cannot get your point regarding the command line input.

marpagu commented 4 years ago

I have completed my tests regarding charsets in the latest version (v1.0.9).

Definitely I was not able to make it work with ISO-8859-1 charset. However, my problems with accent vowels is fixed using a "trick" with the html file. Using a UTF-8 charset in the command line, the subject with accent vowels is properly showed.

On the other hand, the body is also well showed if the html file has been previously saved with a UTF-8 codification. This is, I open the same html file with the notepad and I use "Save as" option, choosing UTF-8 codification. This works using body -file tags but it does not work using attach tag with inline.

Html saved as utf8

My command line are:

mailsend-go.exe -t RECEIVER@mail.com -smtp smtp.office365.com -port 587 -f SENDER@mail.com -sub "Número de documento: TEST/20-000001" auth -user SENDER@mail.com -pass PASSWORD -cs "UTF-8" body -file "C:/simple.html" -mime-type text/html

Body with html file

mailsend-go.exe -t RECEIVER@mail.com -smtp smtp.office365.com -port 587 -f SENDER@mail.com -sub "Número de documento: TEST/20-000001" auth -user SENDER@mail.com -pass PASSWORD -cs "UTF-8" body -file "C:/simple_saved_as_utf8.html" -mime-type text/html

Body with html saved as utf8

mailsend-go.exe -t RECEIVER@mail.com -smtp smtp.office365.com -port 587 -f SENDER@mail.com -sub "Número de documento: TEST/20-000001" auth -user SENDER@mail.com -pass PASSWORD -cs "UTF-8" attach -file "C:/simple_saved_as_utf8.html" -mime-type text/html -inline

Using attach inline with html file saved as utf8

Said this, it would be great to be able to use other charsets, as it is mentioned in #12

Regards, Marcos