1

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 [email protected] < 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 [email protected]?

1
  • Sendmail log output would help. =)
    – Mike B
    May 31, 2012 at 14:35

2 Answers 2

0

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 [email protected]
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.

5
  • 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, 2011 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, 2011 at 22:27
  • Patrick's suggestion makes more sense than mine, if you're already using sendmail. Jan 11, 2011 at 22:33
  • feel free to bump me up a point ;).
    – Patrick R
    Jan 11, 2011 at 23:44
  • Patrick I've given you credit where credit is due, sorry. Jan 11, 2011 at 23:56
1

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   [email protected]

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

apache     [email protected]
root       [email protected]

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 [email protected]

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .