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'm setting up sendmail on my home computer to use with my webserver. I've set it to use my SMTP server provided by my hosting company.

If I use the following command, it works

sendmail -Am -t -v

and then I enter the to and from emails.

But if I try the following, it does not work.

sendmail -v < test.txt

The TO email is the same as in the earlier command, but in this case I haven't specified a FROM e-mail, which I think is the problem.

My guess is that it's sending the mail from user@localhost causing the smtp server to reject it. If so, how do I make it send from

share|improve this question
Sendmail log output would help. =) – Mike B May 31 '12 at 14:35
up vote 0 down vote accepted

I recommend that if your home machine just needs to send email out and not receive it that you set up msmtp instead. It provides all the features you need for sending mail without doing any inbound processing. Here's a sample .msmtprc:

user test
password testpass
auth login

with that, my user can send mail that appears to come from If your webserver user needs to send mail you can configure this for that user.

share|improve this answer
Thanks for the suggestion. I'll give it a try next time. I already got my sendmail to work. It was a silly configuration mistake on my part. The daemon was disabled. My reason to use sendmail was to make it identical to the configurating on my VPS where I'll be moving all my files to after I finish development. Selected as the best answer. Thanks – coder Jan 11 '11 at 22:23
well darn, guess I just took to long to post my answer below. care to give my suggestion a whirl? – Patrick R Jan 11 '11 at 22:27
Patrick's suggestion makes more sense than mine, if you're already using sendmail. – Phil Hollenback Jan 11 '11 at 22:33
feel free to bump me up a point ;). – Patrick R Jan 11 '11 at 23:44
Patrick I've given you credit where credit is due, sorry. – Phil Hollenback Jan 11 '11 at 23:56

You should be able to pull this off by editing your /etc/mail/ file

#vi /etc/mail/


FEATURE(`genericstable',`hash -o /etc/mail/genericstable.db')dnl


#vi /etc/mail/genericstable



So you could make it look like apache or root sent the email as someone else



#vi /etc/mail/generics-domains


next generate new configs and restart sendmail

#makemap -r hash genericstable.db < genericstable
#m4 >
#/etc/init.d/sendmail restart

Now you should be able to send out your email as root or apache or whoever you defined above and it will show up in your inbox as coming from them.

Try out while logged in as root or apache process

#echo "test" | sendmail

You should find that the sender was anotherusername or anotherusername-2

share|improve this answer

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.