1

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%From@EmailAddress>
Aug 11 12:14:32 fs1 postfix/qmgr[4780]: C834918E658F: from=<SystemUsername@PostfixsPrimaryFQDN>, size=1511, nrcpt=1 (queue active)
Aug 11 12:14:32 fs1 postfix/local[237956]: C834918E658F: to=<Recipient@EamilAddress>, 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
postfix-3.5.4-2.fc32.x86_64
Richard T
  • 1,130
  • 11
  • 26
  • @MichaelHampton Found I was slightly in error about the command - the code has two forms of the mailx call, and I thought it was using one, but in fact it's always using the other in this instance - the difference is in a specified "from" instead of just user. And, I added the log data you wanted and a little more. – Richard T Aug 11 '20 at 19:55
  • @MichaelHampton So, acronym overload: Just looked up DSN. Ah, OK, better understand your comment now. Frankly, I don't know how I got it generated, either. I presume it's Potfix generating it since the first line of the DSN says, "This is the mail system at host ". But what tells Postfix to do this?! And why some email and not others? This is why I also presume it's the mix of Postfix and mailx. As for what I may have left out, no idea! The software I'm working in is HUGE, complex, and sophisticated, but I did write it all myself... Ask and I'll share. – Richard T Aug 11 '20 at 20:37
  • Are you 100% certain you haven't sent mail via the `sendmail` command somewhere? – Michael Hampton Aug 11 '20 at 21:22
  • @MichaelHampton Well, the sendmail on my box has a -n flag it ignores, but neither a -s nor a -S, so IDK how it would work. However, lucky me, I designed in a config-file that lets you tell it the mail command. It's presently set as: MailCommand=/bin/mailx -s "%s" -S from="%f" -v %t < %b This string gets parsed and things get substituted, but I COULD change it out to try sendmail if there was some value to trying... ...I've been wrong before, but I'm pretty sure the code is running the mailx, which, BTW, calls itself "Heirloom Mail" if you run it as a full-up mail client. – Richard T Aug 11 '20 at 21:33

1 Answers1

3

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.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • I was aware of the -v but I'm explicitly NOT using it! (Perhaps I could have mentioned I knew about -v - sorry about that.) ... I cut and pasted straight from my config! ... HERE'S A THEORY: There's a new bug that sometimes -v gets turned on in some situations? This would explain the change in behavior. – Richard T Aug 11 '20 at 21:48
  • 1
    @RichardT But `-v` is in the `MailCommand=` that you posted! – Michael Hampton Aug 11 '20 at 21:49
  • IT IS?! -gupl!- – Richard T Aug 11 '20 at 21:49
  • Crap, you're right. How Damned Embarrassing. ...In my defense, there are something like 6 installations on this one box, development, three heavily used production environments, and a couple for testing - I could easily have looked at the wrong one. But when you asked me for the specifics of the command earlier, I hunted down and realized I was looking at the wrong stuff earlier and so I just didn't notice the -v. ... I'm very sorry to have put you through the time sink! :-( But, you'll get some rep points in a second! ;-) – Richard T Aug 11 '20 at 21:54