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

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 name@mydomain.com < 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 user@mydomain.com?

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

2 Answers 2

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:

host smtp.example.com
user test
password testpass
from test@example.com
auth login

with that, my user can send mail that appears to come from example.com. 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/sendmail.cf file

#vi /etc/mail/sendmail.cf

add

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

next

#vi /etc/mail/genericstable

add

username   anotherusername@domain.com

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

apache     anotherusername@mydomain.com
root       anotherusername-2@mydomain.com

next

#vi /etc/mail/generics-domains

add

subdomain.mydomain.com
mydomain.com

next generate new configs and restart sendmail

#makemap -r hash genericstable.db < genericstable
#m4 sendmail.mc > sendmail.cf
#/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 bubba@mydomain.com

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

share|improve this answer

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.