1

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" [email protected] < /dev/null

The body (!) outcome was: No attach!

file.txt
MIME-Version: 1.0
Content-Type: text/plain; charset="ANSI_X3.4-1968"
Content-Transfer-Encoding: 8bit

The file itself was not attached! Only the header of the encoding was apparently sent.

Next try:

uuencode file.txt file.txt | mail -s "Test" [email protected]

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?

3
  • This made it work now: mutt -s "Test" -a file.txt -- [email protected] < /dev/null. But mail behaviour seems different in Ubuntu 18.04 vs 14.04. Hence my question regarding mail remains unanswered.
    – geohei
    Jun 4, 2019 at 20:30
  • I have not checked the details but my suspicion is that the changing syntax reflects the different version of mail / nail / heirloom mail / mailx shipped by the different releases of Ubuntu...
    – andrew.46
    Jun 13, 2019 at 4:51
  • Irrespective of possible syntax changes, mail should nevertheless still be capable of sending attaches somehow. I didn't manage to convice it to send any attach by any command (-a, ...) or pipe (uuencode, ...)!
    – geohei
    Jun 13, 2019 at 9:24

1 Answer 1

1

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.4

In this case the correct syntax for your example would be:

mail -A file.txt -s "Test" [email protected] < /dev/null

Note 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" [email protected] < /dev/null

This was tested thoroughly on my own 18.04 installation and worked well, hopefully it will on yours as well :)

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .