0

I am running a Fedora Virtual Server

I mail one of my users using the following command inside a bash script

/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE

Inside Virtualmin I have setup main forwarding so all mail from the domain gets sent to my gmail account. When I get the message is contains no FROM field. How can I change this to the name of the account on the server?

jax
  • 207
  • 1
  • 5
  • 12

1 Answers1

3

Try using /usr/lib/sendmail with the -t flag:

/usr/lib/sendmail -t < $EMAILMESSAGE

Your file at $EMAILMESSAGE should contain the appropriate header lines, followed by a blank line, followed by your message text:

To: some.address@mydomain.abc
From: my.address@mydomain.abc
Subject: This is my subject line

The text of my message begins here.
micah
  • 974
  • 6
  • 11
  • Thanks! I have a cron job that emails me the output of another program once a day, which I have to check for changes from the previous day. By using your method to manually set headers, I set the In-Reply-To and References headers. This causes Gmail to treat the messages as a conversation thread, which is great because Gmail automatically highlights the changes for me, hiding unchanged text behind "Show quoted text". So now I am using Gmail as a diff tool :) I put this here because I could find no info on using In-Reply-To with the `mail` command, and others may benefit if it is here. – Liam Aug 19 '10 at 15:02