Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 3 down vote accepted

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:

Subject: This is my subject line

The text of my message begins here.
share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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