Solved

Setup sendmail in RHEL 5.3 to use external SMTP

Posted on 2011-03-09
10
2,781 Views
Last Modified: 2012-08-13
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/sendmail.mc as:
define(`SMART_HOST', `mailhost')

2. Add this line to /etc/hosts
10.30.128.4     mailhost

3. Compile settings
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

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.
Regards
0
Comment
Question by:k3pa
  • 5
  • 4
10 Comments
 
LVL 18

Expert Comment

by:TobiasHolm
Comment Utility
Hi!

Have you tried to put brackets around the mailhost?

define(`SMART_HOST',`[mailhost]')dnl

Open in new window


Ref: http://www.linuxquestions.org/questions/slackware-14/sendmail-smtp-auth-howto-224543/#post1144343

Regards, Tobias
0
 
LVL 18

Expert Comment

by:TobiasHolm
Comment Utility
Also, the IP 10.30.128.4 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
0
 
LVL 4

Author Comment

by:k3pa
Comment Utility
I've tried to use this one:
define(`SMART_HOST',`[mailhost]')dnl

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: to=myemail@domain.com, delay=00:03:04, mailer=esmtp, pri=30056, dsn=4.4.3, stat=queued
0
 
LVL 28

Accepted Solution

by:
Jan Springer earned 500 total points
Comment Utility
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):

   host mailhost.domain.com

Configure:
 
   define(`SMART_HOST',`mailhost.domain.com')

And then:

    make -C /etc/mail
    service sendmail reload
0
 
LVL 4

Author Comment

by:k3pa
Comment Utility
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.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 18

Expert Comment

by:TobiasHolm
Comment Utility
You can try to add the "mailhost" host to the local /etc/hosts file.

Regards, Tobias
0
 
LVL 4

Assisted Solution

by:k3pa
k3pa earned 0 total points
Comment Utility
I set up a dns server and names are being resolved ok.

> host mail.domain.com
mail.domain.com has has address 10.30.128.4

I also tested MX record:

> nslookup -query="MX" domain.com
Server:         10.30.128.81
Address:        10.30.128.81#53

domain.com  mail exchanger = 10 mail.domain.com.

I changed sendmail.cf like this:
DSmail.domain.com

However, emails are not sent. :(

Where shoud I do next?
0
 
LVL 18

Expert Comment

by:TobiasHolm
Comment Utility
Can you see anything in the logs to help understand what's wrong?

Regards, Tobias
0
 
LVL 4

Author Comment

by:k3pa
Comment Utility
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 sendmail.cf 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.
Regards.
0
 
LVL 4

Author Closing Comment

by:k3pa
Comment Utility
Fully qualified names and setting up a custom DNS server solved the issue.
0

Featured Post

Do email signature updates give you a headache?

Constantly trying to correctly format email signatures? Spending all of your time at every user’s desk to make updates? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today!

Join & Write a Comment

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Email signatures have numerous marketing benefits. Here are 8 top reasons to turn your email signature into a marketing channel.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now