5

I have written the mailx command like this

echo "${BDY_MSG}" | mailx -r <from_address> -s <subject> <to_address>

Now I need to set the priority of this mail.How do I do that?

sudipta06
  • 658
  • 7
  • 12

1 Answers1

13

You'll have to look at your mailx manpage to see what options are accepted. Two solutions in increasing order of hack-iness:

  • If your mailx supports the -a option to add an additional header option, you can use -a "X-Priority:1".
  • If your mailx does not support the -a option, you can try to hack it in by using this trick from this other post by adding a newline to the subject: -s "$(echo -e "This is the subject\nX-Priority: 1")"
  • If neither of those work for you, you'll need to try another tool.
Community
  • 1
  • 1
Adam B
  • 3,775
  • 3
  • 32
  • 42
  • Perfect hack with -s, although double-quotes inside double-quotes seemed not right, it worked exactly as proposed. – access_granted Feb 25 '22 at 00:49
  • you don't need for a command substitution; using the [ANSI-C Quoting feature](https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html) (see [Which shells support ANSI-C quoting? e.g. $'string'](https://unix.stackexchange.com/q/371827/72456)), that could be simply written as `-s 'subject_here'$'\nX-Priority: 1'`. – αғsнιη Apr 30 '22 at 05:46