Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why does mailx ignore header fields?

I want to send an HTML email.
have a plain text file that looks like this:

From: "name" <[email protected]>
To: [email protected]
Subject: First Email
MIME-Version: 1.0
Content-Type: text/html; charset=us-ascii
Content-Disposition: inline

<strong>Hello, World!</strong>

I run mailx like this,

mailx -t -S smtp=server.com [email protected]  < file

It sends a plain-text email instead and prints:

Ignoring header field "MIME-Version: 1.0"
Ignoring header field "Content-Type: text/html; charset=us-ascii"
Ignoring header field "Content-Disposition: inline"

Why?
How do I send an html email?

Other sources say to use the -a flag and specify the content-type,
but -a on my version of mailx is attachment; so that doesn't work.

like image 810
Trevor Hickey Avatar asked Feb 01 '18 16:02

Trevor Hickey


1 Answers

When using option -t, mailx filters out header fields and only keeps the following ones:

  • to:
  • cc:
  • bcc:
  • from:
  • reply-to:
  • sender:
  • organization:

Any other header produces the "Ignoring header field" warning message and is discarded.

This is effectively cryptic in the manual.

like image 123
ircama Avatar answered Sep 19 '22 14:09

ircama