muquit / mailsend

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

Attachments with Spaces in the Filename (not attached) #81

Closed arrmo closed 8 years ago

arrmo commented 8 years ago

Hi,

It seems that when there are spaces in the filename my attachments are not being attached. I have quoted things "correctly", and mailsend doesn't complain at all, but it doesn't attach the files (both are text files).

I have tried verbose output, but that only seems to related to the SMTP connection, not about the attachments.

More than happy to help debug it, just not sure how to get more info.

Thanks!

muquit commented 8 years ago

I can not seem to reproduce the problem. Here is a test I did in windows with mailsend 1.18. Yes -show-attach is broken in v1.18, will fix, however opening filesnames with spaces does not seem to be a problem.

C:\>mailsend1.18.exe -v -show-attach -port 7865 -smtp localhost -sub "atachment filename with spaces" -to muquit@localhost -from muquit
@localhost -enc-type none -mime-type "text/plain" -attach "z:\filename with space.txt" -attach "z:\filename2 with space.txt"

The mail in the mailbox looks like:

To: muquit@localhost
X-Mailer: @(#) mailsend v1.18 (Windows)
X-Copyright: BSD. It is illegal to use this software for Spamming
Mime-version: 1.0
Content-type: multipart/mixed; boundary="8D8XlNQDkAjJYUbD"
Message-Id: <E1ZOvEx-0002uR-O5@m3>

--8D8XlNQDkAjJYUbD
Content-Type: text/plain; charset=utf-8
Content-Disposition: attachment; filename="filename with space.txt"

this is filename
This is a test
This is a test
The end

--8D8XlNQDkAjJYUbD
Content-Type: text/plain; charset=utf-8
Content-Disposition: attachment; filename="filename2 with space.txt"

This is filename2
This is a test
This is a test
The end

--8D8XlNQDkAjJYUbD--
arrmo commented 8 years ago

Hi,

I’m also using –msg-body, could that perhaps be causing the problem? And I am trying to attach, not put inline … maybe that’s it?

Thanks!

arrmo commented 8 years ago

Yep, that's it! As soon as I remove -msg-body, the attachments are actually attached.

Thoughts?

Thanks!

muquit commented 8 years ago

That's how -msg-body works, it can include only one text or html file and will ignore all other attachments. If you want a text file as mail body you can attach it inline but it will depend on the mail reader to display it as a body. It's mentioned in the FAQ#1. Thanks.

arrmo commented 8 years ago

My apologies! I missed that ... :(.

To clarify then - can I add multiple attachments ... one as inline (in the body), the other as attached files (just flag them appropriately)? Or is it that they all have to be inline or attached?

Thanks!!!

muquit commented 8 years ago

Yes. Each attachment can have its own -enc-type, -mime-type, -disposition, -cs etc. Requirement is they must be specified before the -attach option. Example: -enc-type "none" -mime-type "text/plain" -disposition "inline" -attach "file1.txt" -enc-type "base64" -mime-type "image/png" -disposition "attachment" -attach "file.png" -mime-type "image/gif" -disposition "inline" -attach "file.gif". For the last attachment, -enc-type is not specified, so it will take the previous attachment's encoding type which is base64. Thanks.

arrmo commented 8 years ago

That does it, thanks!

I made them all attachments (no msg-body), and just changed the disposition as needed.

Thanks again!