Change the From: address on the fly for email sent from the command-line

mail -s "subject" <emailbody.txt -- -f -F 'From Display Name'
It's very common to have cron jobs that send emails as their output, but the From: address is whatever account the cron job is running under, which is often not the address you want replies to go to. Here's a way to change the From: address right on the command line. What's happening here is that the "--" separates the options to the mail client from options for the sendmail backend. So the -f and -F get passed through to sendmail and interpreted there. This works on even on a system where postfix is the active mailer - looks like postfix supports the same options. I think it's possible to customize the From: address using mutt as a command line mailer also, but most servers don't have mutt preinstalled.

By: dmmst19
2010-01-18 19:55:27

What Others Think

Thats awesome thanks!
AskApache · 614 weeks ago
Great solution, thank you! My small business IT support team used something similar when we needed a quick solution to our business. I think there are many different options for how this could be solved
DenialSmith701 · 37 weeks and 6 days ago
Thanks for your type info.. I realy appreciate it.. keep it up.">Body contouring near me
nakav51247 · 15 weeks and 3 days ago
Wonderful article. Fascinating to read. I love to read such an excellent article. Thanks! It has made my task more and extra easy. Keep rocking. gas shock ball stud
KayGasaway · 14 weeks and 5 days ago
If you are looking for more information about flat rate locksmith Las Vegas check that right away. wilkinson chute door parts
Audrey10 · 8 weeks and 3 days ago
Hey what a brilliant post I have come across and believe me I have been searching out for this similar kind of post for past a week and hardly came across this. Thank you very much and will look for more postings from you. ??
KayGasaway · 7 weeks and 4 days ago
I exactly got what you mean, thanks for posting. And, I am too much happy to find this website on the world of Google.">Diamond jewellers patiala
KayGasaway · 7 weeks and 3 days ago
I gotta favorite this website it seems very helpful . Buy Whisky online free delivery
Audrey10 · 7 weeks and 1 day ago
This is my first time i visit here and I found so many interesting stuff in your blog especially it's discussion, thank you. ugly cartoon characters
Audrey10 · 6 weeks and 5 days ago
I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much. Paintless Dent Repair San Diego
KayGasaway · 6 weeks and 1 day ago
i really like this article please keep it up. nysc portal
KayGasaway · 6 weeks ago
it was a wonderful chance to visit this kind of site and I am happy to know. thank you so much for giving us a chance to have this opportunity.. tea burn
KayGasaway · 5 weeks and 5 days ago
This is actually the kind of information I have been trying to find. Thank you for writing this information. naija news
KayGasaway · 5 weeks and 1 day ago
I really appreciate this wonderful post that you have provided for us. I assure this would be beneficial for most of the people. pool result
KayGasaway · 4 weeks and 6 days ago
The really gigantic Toto site is called a major site, but a site that people have bet on at least once or heard from people around is called a major site. ?????
gexeji53 · 4 weeks ago
Yes, I am entirely agreed with this article, and I just want say that this article is very helpful and enlightening. I also have some precious piece of concerned info !!!!!!Thanks. ??? ???
KayGasaway · 3 weeks and 6 days ago
Thanks for sharing this information. I really like your blog post very much. You have really shared a informative and interesting blog post with people.. ??????
KayGasaway · 3 weeks and 2 days ago
This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article. remote it support business
KayGasaway · 3 weeks and 1 day ago
this is really nice to read..informative post is very good to read..thanks a lot!
KayGasaway · 2 weeks and 1 day ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: