Posted on

Diagnosing “savemail: cannot save rejected email anywhere”

We recently ran into this message on one of our development servers.   There are a number of reasons this may happen and finding the right solution means finding the cause of the error.  These steps will help you isolate the cause of the error so you can start tracking down the proper solution.  In our case an errant application was not sending the from: field in the mail header thus causing the message to fail the basic mail format checks.

Checking Aliases

First make sure you have the following entries in /etc/aliases:

# Basic system aliases -- these MUST be present
MAILER-DAEMON:    postmaster
postmaster:    root

If these entries are present, try running these commands:

# sendmail -bv MAILER-DAEMON
# sendmail -bv postmaster

It should come back immediately with a message like the one below:

postmaster@cybersprocket.com... deliverable: mailer relay, host [127.0.0.1], user postmaster@cybersprocket.com

If it does not, rebuild the aliases database by running the newaliases command:

# newaliases

Forcing A Resend With Logging

Failed messages remain in the mail queue directory for examination by the system administrator. Sendmail renames the header of the queued message from qf* to Qf*, making it easy to identify these messages in your mail queue.  You can easily list the failed messages with the following mailq command:

# mailq -qL

To diagnose, locate the offending message ID in the log (/var/log/maillog) or by using the mailq -qL command.

Rename the matching Qf<message_id> file to qf<message_id>, and execute the following command:

sendmail -v -qI<message_id> -d11

The Problem Revealed

You should now have a detailed log file indicating what the source of the problem was.  In our case we see the From: line in the mail header is blank:

>>> MAIL From:<>
501 Syntax error in arguments
Data format error

Hope that helps. Good luck!