0

How can I pass a full raw/MIME message (raw file) to the Linux mailx command for delivery? I don't want to extract the recipient, subject, body etc from the message - I want to feed a complete existing raw mail message 'as is' to mailx for sending whilst retaining all existing headers.

An example message is as follows:

Received: (qmail 32389 invoked by uid 0); 13 Jun 2017 09:24:51 -0400
Date: Tue, 13 Jun 2017 09:24:51 -0400
From: root@test.server.com
To: test@test.com
Subject: Test Email
Message-ID: <593fe7a3.IgSR+/BLy+NYXlVZ%root@test.server.com>
User-Agent: Heirloom mailx 12.5 7/5/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

The test mail content

So I want to be able to feed the above to the mailx command on the command line.

The purpose of this is to make the server deliver the original message (exactly as it was read from the raw message file) via a secondary SMTP server - to do this we would use mailx's -S switch to specify the secondary SMTP server eg:

mailx -S smtp="backup-mail-server.com:25" < feed in the MIME message here somehow

How can I do this with mailx?

  • 1
    Then why do you bother with mailx? Use sendmail -t. – Satō Katsura Jun 13 '17 at 18:05
  • @SatoKatsura can you send the message through an external SMTP server with sendmail? That's why I was intending to use mailx. – Chris Jun 13 '17 at 18:08
1
 mailx -S smtp="backup-mail-server.com:25" < mailx -p -f /var/mail/nobody

This will read the RAW mail file, and pipe it into your send.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.