Sendmail: Deliver Mail to External Mail Host

I have my webserver with www.domain.com. My email for the same www.domain.com is hosted elsewhere. I therefore use sendmail to send mail, but not to receive.

I can send mail to users no problem, however if I try to send an email to myself (such as server reports) the mail is not sent. Sendmail logs just say unknown user.

How can I get mail sent to admin@domain.com to be sent to my 3rd party mailhost?

How can I get internal server emails (such as those from cron) to also be sent to my mail host rather than being saved locally on the server?

Thanks
adintensityAsked:
Who is Participating?
 
yuzhCommented:
You can create an aliase for admin to point to the real user (or aliase) in the
 3rd party mailhost.

eg:
aliases file, to make:
admin: admin@otherhosts, fred@somewhere
then run:
newaliase
to update the aliase database
see: http://www.bga.org/~lessem/psyc5112/usail/mail/aliasing/

or use  virtusertable to do the job, please read
Please have a look at the send FAQ:
http://www.sendmail.org/faq/
http://www.akadia.com/services/sendmail_tips.html
http://www.sendmail.org/tips/virtual-hosting.html


BTW, it is better to move this question to the Sendmail TA:
    http://www.experts-exchange.com/Networking/Email_Groupware/Sendmail/


0
 
fpintosCommented:
>I have my webserver with www.domain.com. My email for the same www.domain.com is hosted elsewhere. I therefore use sendmail to send mail, but not to receive.

Do you mean email for domain.com is hosted eleswhere? You need to make sure your MX record for domain.com is setup correctly to point to the IP of your 3rd party hosted email server.

>I can send mail to users no problem, however if I try to send an email to myself (such as server reports) the mail is not sent. Sendmail logs just say unknown user.

Outbound email from www.domain.com to other mail domain will have no problem. If you try to send mail to user@domain.com, the MX record for domain.com is used to lookup the relevant mail server for mail delivery, in this case your email server hosted by 3rd party.

>How can I get mail sent to admin@domain.com to be sent to my 3rd party mailhost?

>How can I get internal server emails (such as those from cron) to also be sent to my mail host rather than being saved locally on the server?

I think your problem lies in incorrectly setup MX record for domain.com. IF your MX record is correct, mail will flow correctly.
0
 
Hanno P.S.IT Consultant and Infrastructure ArchitectCommented:
The problem is that ALL email you send to any adress at domain.com (like joe@domain.com, peter@domain.com or unknown-user@domain.com) all emails will be transferred to your mailgateway for this domain (check the MX record for domain.com):
# nslookup
> set type=MX
> domain.com
 .... some output .... (look for "mail exchanger")
> exit
If there is no user such as "admin" known, sending email will fail.
As already suggested, you may want to add "admin" to /etc/aliases (or /etc/mail/aliases) and run "newaliases" to refresh the internal table from it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.