How do I stop mailx from triggering Postfix's mail delivery report?

Richard T asked:

I have a script that needs to send emails to notify about system events and status – a pretty common use-case, I’d think – and I chose to use mailx for this (why I no longer remember) on my Fedora Server system.

Everything was just fine and dandy until a recent upgrade whereupon I started getting an extra email for every one sent. The first line identifies the mail system host. The second line reads:

Enclosed is the mail delivery report that you requested.

Except that I didn’t knowingly or willingly request the email delivery report! They just started showing up post-upgrade. (Either that, or my client-side spam filter – Thunderbird) was killing them for me, I suppose?! It’s weird, sometimes doing a great job, then suddenly catching nothing at all?! -shrug- )

I suppose I can use an explicit directive in my mail reader’s "filters" to get rid of these, but I’d rather they not be generated in the first place – the emails that are sent are what’s valuable and I just don’t need or want these "delivery report"s.

I started with mailx’s man page. Nothing useful there, or, at least, I didn’t recognize any setting for this type of thing. I STRONGLY suspect this is generated somehow by the interaction of mailx and Postfix, though that’s only a hunch. I get exactly one mail status report per call to mailx, but none when I either send mail via alpine or Thunderbird from the same account through the same Postfix installation.

Here’s the pattern the code uses:

/bin/mailx -n -s "subject" -s from=from_address to_address < content

The -n means don’t read any local configuration. The -S indicates setting a "variable", in this case specifying a from address.

I took the Postfix queue ID and used grep to find it in /var/log/maillog:

Aug 11 12:14:32 fs1 postfix/pickup[233386]: C834918E658F: uid=nnnn from=<SystemUsername>
Aug 11 12:14:32 fs1 postfix/cleanup[237953]: C834918E658F: message-id=<5f32ee18.AXOWyPor64xZtCVH%[email protected]>
Aug 11 12:14:32 fs1 postfix/qmgr[4780]: C834918E658F: from=<[email protected]>, size=1511, nrcpt=1 (queue active)
Aug 11 12:14:32 fs1 postfix/local[237956]: C834918E658F: to=<[email protected]>, relay=local, delay=0.14, delays=0.05/0/0/0.08, dsn=2.0.0, status=sent (delivered to mailbox)
Aug 11 12:14:32 fs1 postfix/bounce[238851]: C834918E658F: sender delivery status notification: E2BC718E6D06
Aug 11 12:14:32 fs1 postfix/qmgr[4780]: C834918E658F: removed

I noticed that sometimes there was an expansion of the delivery address and other times not. So, that would, I’d think, rule out the known quirk where Postfix sends status emails when asked to do expansion validation, "does this exist" checks.

All the deliveries are local in this instance, but they could be remote – I just don’t have a live occurrence of that right now – this is an in-production server.

I’ve looked hard on where to find them, but most all my web searches point me at materials discussing bounce status messages. Nope, wrong thing!

The system:

Fedora Server 32 (booted into 31 presently)
mailx 12.5 7/5/10

My answer:

Aha, I was finally able to reproduce your problem.

The mailx Heirloom Mail command will request a Delivery Status Notification if you use its -v (verbose) option. Unfortunately this behavior appears to be undocumented. The man page only says:

       -v     Verbose mode.  The details of  delivery  are  displayed  on  the
              user's terminal.

Other than requesting a DSN, this option just prints verbose status messages to stdout, which it’s not likely you’re doing anything with anyway.

The only message that -v prints in this case is:

Mail Delivery Status Report will be mailed to <sender>.

You should be fine to remove -v from the command line.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.