mail tool ignores body text from stdin if attachment is added

Bug #1911894 reported by Alexander Fieroch
42
This bug affects 9 people
Affects Status Importance Assigned to Milestone
mailutils (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

This is working:

echo "test - you should see this in mail body!" | mail -s "mail without attachment test" <email address hidden>

If I add an attachment the body is always empty:

echo "test - you should see this in mail body!" | mail --content-filename="file.txt" --content-type="text/plain" --attach="/path/to/file/file.txt" -s "mail attachment test" <email address hidden>

I found an old bug for debian already reporting this but it should be fixed in
mailutils (1:3.5-3) unstable; urgency=medium
 .
   * Cherry-pick patch from upstream git to avoid discarding stdin when
     mail is used to send email with attachments (closes: #918806).

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=918806

So this looks like a regression.

The workaround from the debian bug report above using command option --mime is not working and still sending an empty mail body:

echo "test - you should see this in mail body!" | mail --mime --content-filename="file.txt" --attach="/path/to/file/file.txt" -s "mail attachment test" <email address hidden>

I recognized the bug in Ubuntu 20.04
 mailutils 1:3.7-2.1

and in current Ubuntu 20.10 with
 mailutils 1:3.9-3.2

ProblemType: Bug
DistroRelease: Ubuntu 20.04
Package: mailutils 1:3.7-2.1
ProcVersionSignature: Ubuntu 5.4.0-56.62-generic 5.4.73
Uname: Linux 5.4.0-56-generic x86_64
ApportVersion: 2.20.11-0ubuntu27.14
Architecture: amd64
CasperMD5CheckResult: skip
Date: Fri Jan 15 11:05:17 2021
ProcEnviron:
 TERM=xterm-256color
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: mailutils
UpgradeStatus: Upgraded to focal on 2020-05-22 (237 days ago)

Revision history for this message
Alexander Fieroch (fieroch) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in mailutils (Ubuntu):
status: New → Confirmed
Revision history for this message
David Gräfrath (graefrath) wrote :

I have the exact same issue after upgrading from xenial to bionic. I have a script that does this:

mail --attach "$log_file" --subject "$subject" "$recipient" < "$body_file"

It was working on xenial. After upgrading to bionic, I get a mail with the attached file and an empty body.

Revision history for this message
writer (onino) wrote :

I have the same problem with the difference that the mail body is added as an attachment too.
This only happens if using mail with attachments as descriped above.

I think this problem is solved from mail --version 3.9-7 upwards and related to this debian bug

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=940249

which refers to https://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=3a15565050

From my point of view, this is an important bug, because an email with text and attachments are quiet common and Ubuntu 20.04 is a LTS version.

Information and other users having the same problem refer to

https://askubuntu.com/questions/1332777/mail-mime-version-and-content-type-not-setting-header-mail-behavior-different

https://stackoverflow.com/questions/68470553/behavior-of-sending-email-with-text-and-body-changed-in-ubuntu-20-04-for-mail-fr?noredirect=1#comment121019249_68470553

Revision history for this message
writer (onino) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.