Mutt on Linux has empty text attachments that appear in Yahoo Mail
Asked Answered
M

0

0

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.

Mellie answered 25/1, 2018 at 5:29 Comment(19)
I don't see any attachment in your pastebin; it's just a regular email message with a single line of text in the body. The X-YMailISG header looks like something which could possibly be communicating something to Yahoo behind the scenes; do things improve if you take that out? It seems harmless as per serverfault.com/questions/243466/… thoughMoskowitz
"Yahoo does something wrong" is the understatement of the millennium anyway.Moskowitz
Haha thanks for the reply. Judging from that question you linked, it looks like it's automatically added by Yahoo. I was just trying to figure the difference with a working email though, and potentially found the issue. The only thing that mutt has that a normal email doesn't is Content-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.Mellie
Yeah, that seems like a good clue. By definition, Content-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 saying Content-disposition: attachment which is basically the opposite).Moskowitz
The simple answer seems to be "don't use mutt" 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?)Moskowitz
Yeah unfortunately the entire point is for attachments haha, Vesta CP is installed so exim4 can work for plain text emails. My friend wrote a script using sendmail 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.Mellie
I'll repeat what I already wrote, (some versions of) mailx can conveniently send attachments just like mutt, 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)).Moskowitz
Sorry I thought you were meaning it's on debian only. I'm completely new to Linux in general so just figuring it out as I go along, mailutils installed but mailx wasn't found so I'll give that a proper look later on, just seems a little buggy after trying a couple of examples.Mellie
Here's a smattering of alternatives: #903091 (but really the accepted answer with uuencode is a throwback to the 1980s so that should be absolutely your last resort).Moskowitz
Haha, well after trying heirloom, unfortunately I've found the problem even persists in the default mail 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.Mellie
Then I don't really see any other option than taking the shell script in one of the answers there, peeling off the Content-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 use text/plain instead of text/htmlMoskowitz
I did originally try use my friends (sendmail script)[daco.tech/index.php/Database_backup] as it worked perfectly on his VPS for the past year, however for whatever reason when we tried it on mine, Yahoo would fail the DKIM and not show any text or attachments. To be fair though, I think the attachment issue is due to how Yahoo parses the email, and not how it receives it, as in if a fix is ever made on Yahoo's end, it should hopefully apply to the already existing emails too.Mellie
DKIM is completely unrelated to the content of the mail. The script which is now failing is not doing anything to add DKIM, and so anything with mutt or mailx 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.Moskowitz
Maybe this though, or something like it. answers.launchpad.net/dkimpy/+question/188459Moskowitz
... Do you really have to use Yahoo to receive these messages? The world would be a better place if everyone stopped using them.Moskowitz
Your friend should learn why if [ "$?" -eq 0 ] is an antipattern.Moskowitz
I think the sendmail script was failing the DKIM as I had it enabled in the DNS and it wasn't coded for it, just for some reason Yahoo really hated it. The only reason I'm sticking with Yahoo for this anyway is the 1tb of storage, since it's mainly for archiving and backup. As to that script, I think he was pretty new to coding at the time. I'm new to bash as of this week but tried (my own version)[github.com/Peter92/LinuxBackup/blob/master/file_backup.sh] to make it a bit more adaptable, still feel a little clueless about the weird syntax though after coming from Python lolMellie
You really need quoting and mktemp. Try shellcheck.net for detailed diagnostics.Moskowitz
Thanks for the link, seems really useful. Made the tweaks to keep it happy, but I guess I'll also post on codereview once I'm done to get some proper feedback on what I'm still doing wrong :)Mellie

© 2022 - 2024 — McMap. All rights reserved.