Setup sendmail in RHEL 5.3 to use external SMTP

I am trying to setup sendmail in Red Hat Enterprise Linux to use an external SMTP. I have followed this steps:

1. Uncomment and change this line in /etc/mail/ as:
define(`SMART_HOST', `mailhost')

2. Add this line to /etc/hosts     mailhost

3. Compile settings
m4 /etc/mail/ > /etc/mail/

4. Restart sendmail service
service sendmail restart

Mail is not being delivered and I cannot figure out why. I have manually tested the external SMTP (using telnet mailhost 25, ..., rcpt to:...) and it works. So I am stuck at this point.

Could you please help me out with this one?

Any help would be very appreciated.
Who is Participating?

Improve company productivity with a Business Account.Sign Up

Jan SpringerConnect With a Mentor Commented:
The syntax uses a fully qualified domain name.  The DNS server that this machine is using should be able to resolve the FQDN into that IP:

From the Linux machine, what do you get when you type (substituting the domain name):



And then:

    make -C /etc/mail
    service sendmail reload

Have you tried to put brackets around the mailhost?


Open in new window


Regards, Tobias
Also, the IP isn't a valid external IP, but that depends on how you define "external". It's not a routable IP on the internet.

Regards, Tobias
Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

k3paAuthor Commented:
I've tried to use this one:

But nothing happens. The IP associated to mailhost is indeed within our private network but it's accesible. I don't have any trouble when sending mail throught it from the sendmail host.

Please find below the output from /var/log/maillog:

Mar 10 09:15:24 rhelserver sendmail[13482]: p2A8CKYx013482: from=root, size=56, class=0, nrcpts=1, msgid=<201103100812.p2A8CKYx013482@rhelserver.>, relay=root@localhost
Mar 10 09:15:24 rhelserver sendmail[13482]: p2A8CKYx013482:, delay=00:03:04, mailer=esmtp, pri=30056, dsn=4.4.3, stat=queued
k3paAuthor Commented:
The host is not being resolved. Although the SMTP is whithin our corporate network, it's no so easy to add record to it because of the bureaucracy involved.

I will try to set up a local dns server to target the smtp server.
You can try to add the "mailhost" host to the local /etc/hosts file.

Regards, Tobias
k3paConnect With a Mentor Author Commented:
I set up a dns server and names are being resolved ok.

> host has has address

I also tested MX record:

> nslookup -query="MX"
Address:  mail exchanger = 10

I changed like this:

However, emails are not sent. :(

Where shoud I do next?
Can you see anything in the logs to help understand what's wrong?

Regards, Tobias
k3paAuthor Commented:
Wow it's working now.

Setting up a DNS server with the MX host has worked. It's important to note that I am using the default file. I will have to use this solution because I don't want to spend more time with this issue.

Thank you for your support.
k3paAuthor Commented:
Fully qualified names and setting up a custom DNS server solved the issue.
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.