Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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:

To: some.address@mydomain.abc
From: my.address@mydomain.abc
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
add comment

Your Answer

 
discard

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.