My web provider recently changed from Ubuntu 14.04 to 18.04. This broke an automated script I use to send emails with no body, but with an attach. I shortened the code below to simplfy.
This used to work until now.
mail -a file.txt -s "Test" < /dev/nullThe body (!) outcome was: No attach!
file.txt
MIME-Version: 1.0
Content-Type: text/plain; charset="ANSI_X3.4-1968"
Content-Transfer-Encoding: 8bitThe file itself was not attached! Only the header of the encoding was apparently sent.
Next try:
uuencode file.txt file.txt | mail -s "Test" This time, the body (!) outcome was: No attach was shown!
begin 644 file.txt
M0D5'24XZ5D-!3$5.1$%2#0I615)324]..C(N,`T*4%)/1$E$.BTO+V=E;VAE
M:2!S;V9T=V%R92\O3D].4T=-3"!R;W-T;VEC<R\O14X-"DU%5$A/1#I054),
...This time, the file was encoded apparently, but shown as body, not as attach.
I checked the mailbox on 2 different clients and on a webmail interface. All identical and never any attach.
mutt (instead of mail) also didn't generate file attaches. So I guess the problem is system related, not mail or mutt related.
What goes wrong here?
31 Answer
Small variations the syntax of Gnu Mail / heirloom mailx / nail and friends have historically caused considerable confusion. In the case of Ubuntu 18.04 the default installation is actually mail from Gnu Mailutils. Tested on my own 18.04 installation:
andrew@corinth:~$ mail -V | head -n1
mail (GNU Mailutils) 3.4In this case the correct syntax for your example would be:
mail -A file.txt -s "Test" < /dev/nullNote the upper case -A which differs from your lower case example.
There will also be an informational message from mail complaining about the lack of a body to this email and this message can be avoided by running your example as follows, with an added option:
mail -E 'set nonullbodymsg' -A file.txt -s "Test" < /dev/nullThis was tested thoroughly on my own 18.04 installation and worked well, hopefully it will on yours as well :)
0