3

In Ubuntu 16.04 I used the following command to send an email with text and attachements, which worked fine.

echo "body" | mail -s "Subject" -A "/path/to/attachment" "email@adress"

In Ubuntu 20.04 this command attaches the body-part as an attachment too. The mail --version is 3.7.

Sending only the attachments or only the body is working fine.

This question is about mail from mailutils not mutt nor mailx nor sendmail, etc. A solution is very very welcome. Thx a lot!

onemorequestion
  • 1,056
  • 1
  • 10
  • 15
  • Please define "worked fine". – jhnc Jul 21 '21 at 14:30
  • Worked fine: The mail was send and showed the text "body" as mail content and an attached file named "attachment". Now in 20.04 the mail is empty but have a second attachment which holds the word "body" which is named differently when viewed over differend email clients. – onemorequestion Jul 21 '21 at 14:58
  • Probably a bug. Version 3.11.1 in debian sets `Content-Disposition: inline` as expected. Ubuntu 20.04 has 3.7. – jhnc Jul 21 '21 at 19:28
  • I confirm that I use mail version 3.7 What would you do? Reporting the issue, but whom? Installing 3.11.1 if possible??? Or a version between? Or is there a way to tell mail explicit to use one part inline? Or what else? Thx for your advise in advance. – onemorequestion Jul 21 '21 at 20:35
  • debian bug [940249](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=940249) refers to http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=3a15565050 which appears to have been applied with release-3.9-7. You could report to ubuntu I guess. – jhnc Jul 21 '21 at 21:27
  • If you are willing to use mutt, you could try https://stackoverflow.com/a/55202457/10971581 . Ubuntu also has `mime-construct` – jhnc Jul 21 '21 at 21:31

4 Answers4

1

Thanks a lot to @jhnc for all the information!

This behavior is a bug in mail 3.7 in the package mailutils and adressed in launchpad by 1911894.

But as of today it is unassigned! Not likely to be changed soon.

But Ubuntu 20.04 is a LTS version and sending mail with text and attachements is quite common these days.

If you come along and have the same problem, please fill in a bug report, which is quit easy and helps to increase the importance.

To generate a bug report run in a terminal

apport-cli mailutils

and send it with S to launchpad.

Open browser with 1 and login.

Then enter 1911894 to find the inital bug thread and join. THX!

onemorequestion
  • 1,056
  • 1
  • 10
  • 15
0

Another simple 'solution' is to install the latest mailutils-3.15. This issue is fixed as I verified. Download link: https://mailutils.org/download.html

0

To add to @onemorequestion's answer, I found a workaround in the mailing list for the bug:

you can use the --mime option as a workaround:

echo "body text" | /usr/bin/mail --mime -s "some subject" -A "somefile.csv" my@email.com

This adds the body text as an attachment, but it's better than nothing!

GammaGames
  • 1,617
  • 1
  • 17
  • 32
-1

Attachement with uuencode works fine with UB20.04

( cat body-message.txt; uuencode input-attachment.txt output-attachment.txt ) \
| mail -s "Email With Body Text and Attachment" ****@gmail.com
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Muthu
  • 1
  • 2
  • 1
    It's 2022, uuencode should absolutely not be used. – tripleee Jan 03 '22 at 07:14
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 03 '22 at 08:15
  • @tripleee Agreed ! but when we use the -A option in mail, email body also coming as a attachment. – Muthu Jan 04 '22 at 08:33
  • That depends on the `mail` version; there are multiple incompatible implementations. See perhaps https://stackoverflow.com/questions/17359/how-do-i-send-a-file-as-an-email-attachment-using-linux-command-line/48588035#48588035 – tripleee Jan 04 '22 at 08:40