Sendmail Fails to send emails from Linux server.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sendmail Fails to send emails from Linux server.
# 8  
Old 09-07-2017
Hi,

OK, thanks. Well, that certainly confirms that there is a discrepancy between the macro and the config. If Sendmail was actually having its config properly re-generated, that DS line would read something like DSsmtp.zoho.com, but instead it's blank. Do you have the sendmail-cf package installed ? If not, that might explain why it's not re-building properly. Does your m4 command return any errors when you run it ?

Also, could you provide the output of the following commands, please ? These are to check if Sendmail is hard-configured to masquerade for any particular domains.

Code:
grep -i masq /etc/mail/sendmail.mc
grep ^DM /etc/mail/sendmail.cf
grep ^C\{M /etc/mail/sendmail.cf

Hopefully we'll get to the bottom of this soon. The main thing is to check that you have sendmail-cf installed. If you don't have it installed, then install it, try re-building your config, and see if things start to work.
This User Gave Thanks to drysdalk For This Post:
# 9  
Old 09-07-2017
RedHat

Quote:
Originally Posted by drysdalk
Hi,

OK, thanks. Well, that certainly confirms that there is a discrepancy between the macro and the config. If Sendmail was actually having its config properly re-generated, that DS line would read something like DSsmtp.zoho.com, but instead it's blank. Do you have the sendmail-cf package installed ? If not, that might explain why it's not re-building properly. Does your m4 command return any errors when you run it ?

Also, could you provide the output of the following commands, please ? These are to check if Sendmail is hard-configured to masquerade for any particular domains.

Code:
grep -i masq /etc/mail/sendmail.mc
grep ^DM /etc/mail/sendmail.cf
grep ^C\{M /etc/mail/sendmail.cf

Hopefully we'll get to the bottom of this soon. The main thing is to check that you have sendmail-cf installed. If you don't have it installed, then install it, try re-building your config, and see if things start to work.
I do not know how to check if sendmail-cf is pre-installed or not.

I however, tried installing it anyways. See the Output below.

Code:
[root@development_techx ~]# yum install sendmail-cf
Loaded plugins: fastestmirror, replace
base                                                                                                                                                  | 3.6 kB  00:00:00
centos-sclo-rh                                                                                                                                        | 2.9 kB  00:00:00
centos-sclo-sclo                                                                                                                                      | 2.9 kB  00:00:00
cwp                                                                                                                                                   | 2.9 kB  00:00:00
epel/x86_64/metalink                                                                                                                                  |  12 kB  00:00:00
epel                                                                                                                                                  | 4.3 kB  00:00:00
extras                                                                                                                                                | 3.4 kB  00:00:00
mariadb                                                                                                                                               | 2.9 kB  00:00:00
remi-safe                                                                                                                                             | 2.9 kB  00:00:00
Not using downloaded repomd.xml because it is older than what we have:
  Current   : Wed Aug 30 17:35:30 2017
  Downloaded: Sat Aug 26 05:24:20 2017
updates                                                                                                                                               | 3.4 kB  00:00:00
webtatic                                                                                                                                              | 3.6 kB  00:00:00
(1/2): epel/x86_64/updateinfo                                                                                                                         | 817 kB  00:00:01
(2/2): epel/x86_64/primary_db                                                                                                                         | 4.8 MB  00:00:02
Loading mirror speeds from cached hostfile
 * base: mirrors.kernel.org
 * epel: mirror.sfo12.us.leaseweb.net
 * extras: mirrors.kernel.org
 * remi-safe: mirrors.thzhost.com
 * updates: mirrors.kernel.org
 * webtatic: sp.repo.webtatic.com
Package sendmail-cf-8.14.7-4.el7.noarch already installed and latest version
Nothing to do

After this i ran
Code:
m4 /etc/mail/sendmail.mc > /etc/mailsendmail.cf

There is no output generated but i did make sure the command did not error using echo $? returning 0

I then restarted the smtp service but mail still does not work.

Seems the cf is still not generated properly.

Code:
1.
grep ^DS /etc/mail/sendmail.cf
DS

2. 
grep -i masq /etc/mail/sendmail.mc

dnl MASQUERADE_AS(`mydomain.com')dnl
dnl # masquerade not just the headers, but the envelope as well
dnl FEATURE(masquerade_envelope)dnl
dnl # masquerade not just @mydomainalias.com, but @*.mydomainalias.com as well
dnl FEATURE(masquerade_entire_domain)dnl
dnl MASQUERADE_DOMAIN(localhost)dnl
dnl MASQUERADE_DOMAIN(localhost.localdomain)dnl
dnl MASQUERADE_DOMAIN(mydomainalias.com)dnl
dnl MASQUERADE_DOMAIN(mydomain.lan)dnl

3.
grep ^DM /etc/mail/sendmail.cf

No Output

4.
grep ^C\{M /etc/mail/sendmail.cf

No Output

Please suggest if you spot anything or need more info.
# 10  
Old 09-07-2017
Hi,

Hmm, I'm afraid I'm not really sure why you're having this problem of your config not building correctly. At least we can be sure your Sendmail isn't masquerading as zoho.com or anything like that, so all it should need (all other things being equal, anyway) is the smart relay actually getting set.

Now, I wouldn't normally recommend this these days, but it is possible to edit the sendmail.cf file directly. This is usually a bad idea for two reasons: firstly because it's a lot easier to get things very badly wrong, and secondly because it puts the config out-of-sync with the macro, but that already seems to be broken anyway for some reason.

So, you could always try changing the DS line in your sendmail.cf so that it read:

Code:
DSsmtp.zoho.com

and then re-start Sendmail and see if it works. There should be no way at all that Sendmail can ignore your smart relay then.

Again, normally this is about as far from recommended procedure as it's possible to get, but since your Sendmail macro is somehow already broken anyway, you don't have much else to lose at this point by hand-hacking your sendmail.cf.

Oh, and one important thing: if you're going to do this, back up your sendmail.cf first !
# 11  
Old 09-07-2017
Error

Quote:
Originally Posted by drysdalk
Hi,

Hmm, I’m afraid I’m not really sure why you’re having this problem of your config not building correctly. At least we can be sure your Sendmail isn’t masquerading as zoho.com or anything like that, so all it should need (all other things being equal, anyway) is the smart relay actually getting set.

Now, I wouldn’t normally recommend this these days, but it is possible to edit the sendmail.cf file directly. This is usually a bad idea for two reasons: firstly because it’s a lot easier to get things very badly wrong, and secondly because it puts the config out-of-sync with the macro, but that already seems to be broken anyway for some reason.

So, you could always try changing the DS line in your sendmail.cf so that it read:

Code:
DSsmtp.zoho.com

and then re-start Sendmail and see if it works. There should be no way at all that Sendmail can ignore your smart relay then.

Again, normally this is about as far from recommended procedure as it’s possible to get, but since your Sendmail macro is somehow already broken anyway, you don’t have much else to lose at this point by hand-hacking your sendmail.cf.

Oh, and one important thing: if you’re going to do this, back up your sendmail.cf first !
I took a backup of sendmail.cf and then edited sendmail.cf using vi editor.

Added DSsmtp.zoho.com

Code:
grep ^DS /etc/mail/sendmail.cf
DSsmtp.zoho.com

I then restarted sendmail service as below.

Code:
service sendmail restart
Restarting sendmail (via systemctl):                       [  OK  ]

Once restarted i tried sending the email using the command
Code:
echo "httretrtr" | mail mohtashim@techx.com

but it still DOES NOT work.

I am sharing the maillog hoping it may help get pointers.

Quote:
Sep 7 16:48:13 Development_techx sendmail[18621]: v87GmDhP018621: from=root, size=208, class=0, nrcpts=1, msgid=<201709071648.v87GmDhP018621@techx.com>, relay=root@localhost
Sep 7 16:48:13 Development_techx sendmail[18622]: v87GmDiN018622: from=<root@techx.com>, size=442, class=0, nrcpts=1, msgid=<201709071648.v87GmDhP018621@techx.com>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
Sep 7 16:48:13 Development_techx sendmail[18621]: v87GmDhP018621: to=mohtashim@techx.com, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30208, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (v87GmDiN018622 Message accepted for delivery)
Sep 7 16:48:13 Development_techx sendmail[18623]: v87GmDiN018622: to=<mohtashim@techx.com>, ctladdr=<root@techx.com> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30639, dsn=2.0.0, stat=Sent
A system REBOOT also did not help Smilie
# 12  
Old 09-07-2017
Hi,

OK, I’m starting to run out of ideas off the top of my head, but we’re not totally done yet. One further possibility: does your system believe that it is in fact smtp.techx.com or techx.com? That’s one remaining possible explanation here.

So, some commands it might be useful to see the output of now include:

Code:
hostname 
grep -i techx /etc/hosts
grep hosts: /etc/nsswitch.conf
cat /etc/mail/service.switch

That last one might not exist, but it might - if it does, it would be interesting to see the contents, and it might well be our culprit.

Basically, at this point we’re now attempting to determine if your system believes it is in fact techx.com purely on the basis of hosts file entries, and also we want to see exactly how your system is configured to resolve hostnames when it encounters them.

Beyond that, I’m not sure what else to suggest. I’ve never known a smart relay entry to fail to work. Either something more fundamental is over-riding the behaviour of Sendmail, or it believes that it is in fact smtp.techx.com, and so is actually behaving correctly, so to speak.

EDIT: One last thing. What IP does your system resolve smtp.techx.com and techx.com to be, and are they in fact the same IP as your system ?
# 13  
Old 09-08-2017
RedHat

Note: Although my server is techx.xom we are using a third party external smtp mail server i.e smtp.zoho.com (which listens on port 587 while port 25 timesout when you do telnet to smtp.zoho.com)

There is nothing like smtp.techx.com anywhere as we are using external mail server smtp.zoho.com

Now answering your query. Please find the output below.

Code:
[root@development_techx ~]# hostname
development_techx
[root@development_techx ~]# grep -i techx /etc/hosts
127.0.0.1 techx.com
::1       Development_techx
127.0.0.1 autoreply.Development_techx
45.77.141.129     techx.com
127.0.0.1     localhost development_techx  techx.com Development_techx
#127.0.0.1     localhost localhost.localdomain  techx.com
45.77.141.129 techx.com
[root@development_techx ~]# grep hosts: /etc/nsswitch.conf
#hosts:     db files nisplus nis dns
hosts:      files dns myhostname
[root@development_techx ~]# cat /etc/mail/service.switch
cat: /etc/mail/service.switch: No such file or directory
[root@development_techx ~]# nslookup smtp.techx.com
Server:         108.61.10.10
Address:        108.61.10.10#53

** server can't find smtp.techx.com: NXDOMAIN

[root@development_techx ~]# nslookup techx.com
Server:         108.61.10.10
Address:        108.61.10.10#53

Non-authoritative answer:
Name:   techx.com
Address: 45.76.182.101

Based on this i realized that the /etc/hosts of my other server [45.76.182.101] also contains 127.0.0.1 techx.com and 45.76.182.101 techx.com and as you can see in the output above the nslookup to techx.com points to the other server and not the server we are dealing with.

If i change my server's /etc/hosts file entry form techx.com to dev.techx.com and then restart everything and try sending the Mail
Code:
echo "hello" | mail mohtashim@techx.com

it still fails but this time i get the following error in the the maillogs.

Quote:
Sep 8 05:29:59 Development_techx sendmail[2258]: v885TxEh002258: from=root, size=204, class=0, nrcpts=1, msgid=<201709080529.v885TxEh002258@dev.techx.com>, relay=root@localhost
Sep 8 05:29:59 Development_techx sendmail[2259]: v885TxBG002259: from=<root@dev.techx.com>, size=450, class=0, nrcpts=1, msgid=<201709080529.v885TxEh002258@dev.techx.com>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
Sep 8 05:29:59 Development_techx sendmail[2258]: v885TxEh002258: to=mohtashim@techx.com, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30204, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (v885TxBG002259 Message accepted for delivery)
Sep 8 05:30:01 Development_techx sendmail[2261]: STARTTLS=client, relay=smtp.zoho.com., version=TLSv1/SSLv3, verify=FAIL, cipher=AES128-SHA, bits=128/128
Sep 8 05:30:01 Development_techx sendmail[2261]: v885TxBG002259: to=<mohtashim@techx.com>, ctladdr=<root@dev.techx.com> (0/0), delay=00:00:02, xdelay=00:00:02, mailer=relay, pri=120450, relay=smtp.zoho.com. [8.40.222.118], dsn=5.0.0, stat=Service unavailable
Sep 8 05:30:01 Development_techx sendmail[2261]: v885TxBG002259: v885U1BG002261: DSN: Service unavailable

Sep 8 05:30:01 Development_techx sendmail[2261]: v885U1BG002261: to=<root@dev.techx.com>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31679, dsn=2.0.0, stat=Sent
I then used the following script to send the email for better verbose.

Code:
more test.sh
#!/bin/sh
TO=mohtashim@techx.com

# -i  - do not treat special lines starting with "."
# -v  - use verbose mode (provide SMTP session transcript)
# -Am - use sendmail.cf (do not send via localhost:25) - requires root privileges
/usr/sbin/sendmail -i -v -Am -- $TO <<END
Subject: Delivery test
To: $TO

Delivery test.
END

The output:
Quote:
[root@development_techx ~]# ./test.sh
mohtashim@techx.com... Connecting to smtp.zoho.com. port 587 via relay...
220 mx.zohomail.com SMTP Server ready September 7, 2017 10:20:00 PM PDT
>>> EHLO dev.techx.com
250-mx.zohomail.com Hello dev.techx.com (45.77.141.129 (45.77.141.129))
250-STARTTLS
250 SIZE 53477376
>>> STARTTLS
220 Ready to start TLS.
>>> EHLO dev.techx.com
250-mx.zohomail.com Hello dev.techx.com (45.77.141.129 (45.77.141.129))
250-AUTH LOGIN PLAIN
250 SIZE 53477376
>>> MAIL From:<root@dev.techx.com> SIZE=66
530 5.5.1 Authentication Required.
root... Connecting to local...
root... Sent
Closing connection to smtp.zoho.com.
>>> QUIT
221 mx.zohomail.com closing connection
You have new mail in /var/spool/mail/root
Not sure is the bold red is concerning and a cause of failure.

Please suggest.

Last edited by mohtashims; 09-08-2017 at 02:46 AM..
# 14  
Old 09-08-2017
Hi,

Well done - yes, it was indeed the hosts file entry that would have been the issue. Now, your smart relay is working. But what this error indicates is that smtp.zoho.com requires you to log in or otherwise authenticate beofre you can send mail through it.

What this tells us is that smtp.zoho.com isn’t meant to act as a mail relay or smart host, but rather is just a server for customers to send mail through via a mail client. This is different from a server that can act as a smart host. The general idea of an SMTP smart host is that it takes mail from hosts that would otherwise be unable or unwilling to deliver mail straight to their target on the Internet via SMTP, and it deals with passing the e-mails on to their final destinations. This it would seem is not the configured purpose of smtp.zoho.com.

However, all is not lost. Sendmail can be configured to support this situation, by having a file that tells it how to log in to smtp.zoho.com. You will need a valid username and password for the Zoho e-mail service, and you’d also need to be sure that the maintainers of smtp.zoho.com would be happy for their service to be used as a smart relay. But if all of that is fine, then what you need to do is set up a file called /etc/mail/authinfo with the login details.

Now, one thing that worries me here is that your Sendmail setup for whatever reason seems to be largely ignoring your macro, and so unless /etc/mail/authinfo is already set up in your Sendmail configuration (and it very well may be - have a look and see if it’s mentioned in the .cf), then it’s going to be a very unpleasant job to hack this into working shape.

Anyway, the format of /etc/mail/authinfo (which would then need compiled via makemap hash /etc/mail/authinfo < /etc/mail/authinfo in the usual way) is:

Code:
AuthInfo:smtp.zoho.com "U:USERNAME" "P:PASSWORD" "M:PLAIN"

This sets up authentication for smtp.zoho.com, with the specified username and password, and tells it to use plain-text authentication (which may or may not be right - you’d have to know what kind of authentication is supported for the Zoho SMTP service).

In short: without a working Sendmail macro this could be a lot of work to get up and running. A better bet here is to find another host on your network that can actualy be configured to act as a genuine smart relay for your domain, and to just set Sendmail up to use that host as its smart relay rather than this external service.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to configure mutt to send emails on Linux.?

Hello, I am trying to use mutt in order to send emails. I have installed mutt using yum and pasted some details about it later in the post. When I try to run: echo test | mutt -s "Test Email" user@id.com It doesn't do anything. I dont receive any emails. I have the SMTP details for... (1 Reply)
Discussion started by: vaibhavraj
1 Replies

2. AIX

Sendmail daemon is inactive, but still i can send emails

Hi, I did setup sendmail on one of AIX LPARs. Its working as expected. But, would like to clarify something with you all. I stopped the sendmail daemon on AIX LPAR, now it is inactive(&commented it on /etc/rc.tcpip ). But still, am able to send the emails even after stopping daemon. ... (6 Replies)
Discussion started by: system.engineer
6 Replies

3. UNIX for Dummies Questions & Answers

Emails sent from Linux server are rejected by recipient

Hello i have this longterm issue which im unable to solve, i think this is quite simple issue, i hope you may know the cause It is on CentOS Redhat server with qmail installed. # service qmail status # service qmail start Starting Qmail: # ps aux | grep mail qmails 1688 0.0 0.0 ... (1 Reply)
Discussion started by: postcd
1 Replies

4. Linux

Sendmail takes too long to start and the host is unable to send emails

Hello All, Sendmail takes too long to start and the host is unable to send emails, below are the steps followed, Please let me know if I'm missing anything, is there a debug mode for mailx? # time service sendmail restart Shutting down sm-client: Shutting... (6 Replies)
Discussion started by: lovesaikrishna
6 Replies

5. UNIX for Advanced & Expert Users

mailx Vs sendmail to send internal emails to exchange

Hi Gurus, I have been searching for this around, but sendmail seems complicated and not sure if "mail" command would do, since all what I need to send internal emails from my solaris 10 box to our exchange server. Would the mailx or mail command do ? I tried the : # mailx -s test... (2 Replies)
Discussion started by: aladdin
2 Replies

6. UNIX for Dummies Questions & Answers

Can't configure sendmail to send mails to external SMTP Server

Hi all,I know, that this is very common issue, but I can't find where is the problem... I have Solaris 10 installed.I want to send mail to external SMTP server, like:echo "letter body"| mailx -s "subject" test@test.comBut I donno what kind of changes I have to do in /etc/hosts and sendmail.cf or... (5 Replies)
Discussion started by: nypreH
5 Replies

7. Shell Programming and Scripting

Send email from sendmail on AIX using exchange server as SMTP server

i am new in AIX i am trying to write a script to take a backup for specific files on server to and check error log if backup success send email to administrator , script done except for sending mail , i try to configure sendmail on aix to use our exchange server to send emails but still get error... (0 Replies)
Discussion started by: ahmed_salah
0 Replies

8. UNIX for Dummies Questions & Answers

How do I configure Linux server to be able to send emails internally?

Hi The script: #!/bin/sh #set -x # set admin email so that you can get email ADMIN="myemailaddress" # set alert level ALERT=4 df -HP | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output; do #echo $output usep=$(echo $output | awk '{ print... (5 Replies)
Discussion started by: wbdevilliers
5 Replies

9. Red Hat

Sendmail fails receiving mail since the IP changed on Redhat Server

Hi, Since i move my Linux Redhat server on another Network with new IP address. WE'RE ABLE TO SEND MAIL OUTSIDE BUT we can not receive any incoming mail. It alway points to the old IP. I updated new IP in /etc/hosts and /etc/sysconfig/network then reboot the system. 10.117.32.20 is an old ip... (3 Replies)
Discussion started by: lamoul
3 Replies

10. Solaris

how to send mails to users on exchange server from sendmail/solaris(mailx)

Hi, Can anyone pls. tell me how to access Active directory from solaris. I am looking at solution by which I can send mail notification from the logs generated by scripts, to the users on Exchange server. I am trying for a Perl-LDAP module , but don't realy know how to go for it (5 Replies)
Discussion started by: ganeshh
5 Replies
Login or Register to Ask a Question