I'm trying to set up a script on my VPS where it'll email backup files. I found that mutt
seems to be the email to use for attachments, but I'm getting a weird text file appearing in each email and can't figure out why.
The text file is a few dozen bytes at the most, and is either called 1.txt
with attachments or TEXT.txt
without attachments.
It even happens on super simple examples like this:
echo "Test body" | mutt -s "Test subject" [email protected]
I tried it on dropmail.me and it didn't show the attachment, so I assume it's a minor issue that Yahoo processes wrongly. I had a google but couldn't find the right terms to search for, since it's only ever happened when sending email through mutt
. Sending through sendmail
is fine.
Here is a pastebin of the raw data of an email with no attachments.
mutt
has that a normal email doesn't isContent-Disposition: inline
, and judging from this post (with sadly no replies), it's caused other people some issues too. Slight problem in I can only figure how to change headers and not remove them. – MellieContent-disposition: inline
is implied for text/plain and text/html but rarely spelled out; they seem to be interpreting it exactly wrong (as if it were sayingContent-disposition: attachment
which is basically the opposite). – Moskowitzmutt
" but it's hard to find other mail programs with reliably and predictably allow you to send well-formed MIME messages. If really all you need is plain text,mail
/mailx
should work fine as a replacement (and some versions even allow you to put attachments if you want to, but it's not portable; there are multiple incompatible implementations. If you are on Debian, look for the mailutils one ... I think?) – Moskowitzexim4
can work for plain text emails. My friend wrote a script usingsendmail
where it composed the raw email, but again, yahoo caused issues in the attachments not showing when I tried it on my VPS. The only thing at the moment I can think of is would you happen to know if there's another header where I can clarify it's text only? I seem to be able to add new headers easily, just not modify existing. – Melliemailx
can conveniently send attachments just likemutt
, probably without adding this correct but pesky header, but you have to find a version which is known to do that and which exists for your platform. It's a morass. If not mailutils then maybe look at Heirloom: heirloom.sourceforge.net/mailx.html (Debian package s-nail (sic)). – Moskowitzmailutils
installed butmailx
wasn't found so I'll give that a proper look later on, just seems a little buggy after trying a couple of examples. – Mellieuuencode
is a throwback to the 1980s so that should be absolutely your last resort). – Moskowitzmail
which is a bit of a pain. Shame there's no chance to even mention it to Yahoo anywhere, looks like it's been an issue for many months. – MellieContent-disposition: inline
from that as suggested in a comment, and saving that as a simple local script. If there is a problem with that script, there are many others here, including I suspect more than one by yours truly. Googling for "cat sendmail site:stackoverflow.com" gets me many answers, some of which have the additional complication of including an inline HTML body part; but obviously just usetext/plain
instead oftext/html
– Moskowitzmutt
ormailx
is going to bump into the same issue. When you have a well-formed email, you submit the message to (the local equivalent of)sendmail
which then proceeds to add a signature if it's configured to do that. If it's not properly authorized to do that, or if it adds an incorrect signature, or if it's not configured to add a signature for messages which require it, the recipient will rightfully reject the message. – Moskowitzif [ "$?" -eq 0 ]
is an antipattern. – Moskowitzmktemp
. Try shellcheck.net for detailed diagnostics. – Moskowitz