We help IT Professionals succeed at work.

SENDMAIL to external SMTP server port 2626

harrietcarter
on
I am trying to set up a LINUX sendmail to relay to my external server.  I use this on a virtual machine I demo with so I can't have sendmail send directly.

My external server accepts SMTP on port 2626.

Example Info:

External server: mymail.mysite.com
User name:   myuser
Password:    mypass

What should the text be in
/etc/mail/auth/client-info

What changes to the
/etc/mail/sendmail.mc

Thanks
Comment
Watch Question

You will need the following changes to sendmail.mc in the code snippet below.

In /etc/mail/access just put

  AuthInfo:mymail.mysite.com "U:smmsp" "I:myuser" "P:mypass"

Then do:

  cd /etc/mail && make

That will build /etc/mail/access.db.  You don't need to put AuthInfo in /etc/sendmail.mc unless you're running a very old sendmail (8.12x or earlier), and if you are you should upgrade.
define(`SMART_HOST',`relay:mymail.mysite.com')dnl
define(`RELAY_MAILER',`esmtp')dnl
define(`RELAY_MAILER_ARGS', `TPC $h 2626')dnl

Open in new window

Author

Commented:
Where do I put lines 1-3 that you provided?  I am running Centos 5.7.
Thanks.

Author

Commented:
Never mind,  I think I got it.  I can't test until later today.
Thanks.
The lines can go pretty much anywhere in the mc, but then you have to use m4 to rebuild sendmail.cf (you will need the sendmail-cf package installed)

Let me know how it goes.

Author

Commented:
It still does not send...  are there logs that could help you see my issue?

Author

Commented:
Dec  5 22:09:17 pbx sendmail[1314]: alias database /etc/aliases rebuilt by root
Dec  5 22:09:17 pbx sendmail[1314]: /etc/aliases: 76 aliases, longest 10 bytes, 765 bytes total
Dec  5 22:09:17 pbx sendmail[1319]: starting daemon (8.13.8): SMTP+queueing@01:00:00
Dec  5 22:09:17 pbx sm-msp-queue[1327]: starting daemon (8.13.8): queueing@01:00:00
Dec  5 22:09:21 pbx sendmail[1332]: pB639L3s001332: from=root, size=13, class=0, nrcpts=1, msgid=<201112060309.pB639L3s001332@pbx.local>, relay=root@localhost
Dec  5 22:09:21 pbx sendmail[1333]: pB639Ll5001333: from=<root@pbx.local>, size=277, class=0, nrcpts=1, msgid=<201112060309.pB639L3s001332@pbx.local>, proto=ESMTP, daemon=MTA, relay=pbx.local [127.0.0.1]
Dec  5 22:09:21 pbx sendmail[1332]: pB639L3s001332: to=bergey@thebergeys.com, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30013, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (pB639Ll5001333 Message accepted for delivery)
Did you rebuild sendmail.cf (check the date on the file, is it current?) and restart sendmail prior to sending the message?

The log you just pasted shows that it used the local mailer, not the smarthost.

Author

Commented:
domaintable  mailertable       sendmail.cf.bak  submit.mc
root@pbx:/etc/mail $ ls -al
total 368
drwxr-xr-x   3 root root  4096 Dec  5 22:02 .
drwxr-xr-x 100 root root 12288 Dec  5 21:59 ..
-rw-r--r--   1 root root   440 Dec  5 21:53 access
-rw-r-----   1 root root 12288 Dec  5 21:54 access.db
drwx------   2 root root  4096 Dec  5 16:43 auth
-rw-r--r--   1 root root     0 Aug 11 13:32 domaintable
-rw-r-----   1 root root 12288 Dec  3 13:47 domaintable.db
-rw-r--r--   1 root root  5521 Aug 11 13:32 helpfile
-rw-r--r--   1 root root    64 Aug 11 13:32 local-host-names
-rw-r--r--   1 root root     0 Aug 11 13:32 mailertable
-rw-r-----   1 root root 12288 Dec  3 13:47 mailertable.db
-rw-r--r--   1 root root  1048 Aug 11 13:32 Makefile
-rw-r--r--   1 root root 58284 Dec  5 22:02 sendmail.cf
-rw-r--r--   1 root root 58290 Aug 11 13:32 sendmail.cf.bak
-rw-r--r--   1 root root  7337 Dec  5 21:58 sendmail.mc
-rw-r--r--   1 root root 40322 Dec  3 13:52 submit.cf
-r--r--r--   1 root root 41371 Aug 11 13:32 submit.cf.bak
-rw-r--r--   1 root root   940 Aug 11 13:32 submit.mc
-rw-r--r--   1 root root   127 Aug 11 13:32 trusted-users
-rw-r--r--   1 root root     0 Aug 11 13:32 virtusertable
-rw-r-----   1 root root 12288 Dec  3 13:47 virtusertable.db

Author

Commented:
I did put the smarthost at the end of the sendmail.   This is at the start of the AUTH file...


# by default we allow relaying from localhost...
Connect:localhost.localdomain           RELAY
Connect:localhost                       RELAY
Connect:127.0.0.1                       RELAY

Author

Commented:
Tail end of sendmail.mc

dnl FEATURE(masquerade_entire_domain)dnl
dnl #
dnl MASQUERADE_DOMAIN(localhost)dnl
dnl MASQUERADE_DOMAIN(localhost.localdomain)dnl
dnl MASQUERADE_DOMAIN(mydomainalias.com)dnl
dnl MASQUERADE_DOMAIN(mydomain.lan)dnl
MAILER(smtp)dnl
MAILER(procmail)dnl
dnl MAILER(cyrusv2)dnl
define(`SMART_HOST',`relay:mail.thebergeys.com')dnl
define(`RELAY_MAILER',`esmtp')dnl
define(`RELAY_MAILER_ARGS', `TPC $h 2626')dnl
> I did put the smarthost at the end of the sendmail.   This is at the start of the AUTH file...

What is AUTH file?  There is no such thing in sendmail.  Please be very specific with what you're doing.

Please show me:

1)  The smarthost line(s) from /etc/sendmail.cf
2)  The appropriate portion of /etc/mail/access that you added
3)  The output of "diff sendmail.cf sendmail.cf.bak"

Author

Commented:
I said auth, but I was referring to the access.  

diff results
root@pbx:/etc/mail $ diff sendmail.cf sendmail.cf.bak
19,21c19,21
< ##### built by root@pbx.local on Mon Dec 5 22:02:18 EST 2011
< ##### in /etc/mail
< ##### using /usr/share/sendmail-cf/ as configuration include directory
---
> ##### built by mockbuild@builder10.centos.org on Thu Aug 11 13:32:26 EDT 2011
> ##### in /builddir/build/BUILD/sendmail-8.13.8/cf/cf
> ##### using ../ as configuration include directory
101c101
< DSrelay:mail.thebergeys.com
---
> DS



Contest of acces

root@pbx:/etc/mail $ cat access
# Check the /usr/share/doc/sendmail/README.cf file for a description
# of the format of this file. (search for access_db in that file)
# The /usr/share/doc/sendmail/README.cf is part of the sendmail-doc
# package.
#
# by default we allow relaying from localhost...
Connect:localhost.localdomain           RELAY
Connect:localhost                       RELAY
Connect:127.0.0.1                       RELAY
AuthInfo:mail.thebergeys.com "U:smmsp" "l:test@thebergeys.com" "P:LCBtest1"

root@pbx:/etc/mail $
Okay, I see one problem:

    define(`SMART_HOST',`relay:mail.thebergeys.com')dnl

should be

    define(`SMART_HOST',`mail.thebergeys.com')dnl

The original directions I gave you were wrong on that part.  Please fix sendmail.mc, rebuild sendmail.cf, restart sendmail and then send another test message, and let me see what /var/log/maillog looks like for that transaction.

Everything else looks good - we are close!  BTW, how are you sending the mail?  Are you doing it via the Unix mail command locally, or are you using a remote email client which is set to use mail.thebergeys.com as a relay?

Author

Commented:
I am sending from the command line.

rebooting the server for another issue.  I will send the log file ASAP
Um, you are not running sendmail - you are running exim:

xterm@dellxps:~$ telnet mail.thebergeys.com 2626
Trying 184.154.6.231...
Connected to thebergeys.com.
Escape character is '^]'.
220-cx20.justhost.com ESMTP Exim 4.69 #1 Tue, 06 Dec 2011 16:52:43 -0600
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
quit
221 cx20.justhost.com closing connection
Connection closed by foreign host.

Author

Commented:
Here is the full log.  It looks like it was trying to send directly to my mx records (inbound filter) instead of my mail server. maillog
Those logs only go up until last night at 11:30, and they are local relay logs (probably as a result of calling sendmail directly)  The daemon running on port 2626 is Exim.  You have multiple MTAs installed, so you need to figure out which one you're trying to set up.

Exim logs to /var/log/exim_mainlog, and I'm betting that is where your last test emails were logged.

Author

Commented:
Not there...


root@pbx:/var/log $ ls
acpid            cron                maillog.1        scrollkeeper.log
anaconda.log     cron.1              messages         secure
anaconda.syslog  dmesg               messages.1       secure.1
asterisk         fail2ban.log        mysqld.log       spooler
audit            faillog             pm               spooler.1
boot.log         fpbxpopulate.log    ppp              tallylog
boot.log.1       httpd               prelink          update-fixes.log
brcm-iscsi.log   install-purple.log  rpmpkgs          vsftpd.log
btmp             lastlog             rpmpkgs.1        vsftpd.log.1
conman           mail                rpmpopulate.log  wtmp
conman.old       maillog             samba            yum.log
root@pbx:/var/log $

Do you understand what I'm telling you?  You are not running sendmail.  This is what I get when I telnet to your mail server:

xterm@dellxps:~$ telnet mail.thebergeys.com 2626
Trying 184.154.6.231...
Connected to thebergeys.com.
Escape character is '^]'.
220-cx20.justhost.com ESMTP Exim 4.69 #1 Tue, 06 Dec 2011 16:52:43 -0600
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
quit
221 cx20.justhost.com closing connection

This is what a Sendmail server looks like:

[colinb@foo ~]$ telnet myserver.com 25
Trying 10.10.10.10...
Connected to myserver.com.
Escape character is '^]'.
220 myserver.com ESMTP Sendmail 8.13.8/8.13.8; Tue, 6 Dec 2011 18:41:52 -0500
quit
221 2.0.0 myserver.com closing connection
Connection closed by foreign host.

Author

Commented:
My time was off on the system....

Resent... Here is the log data


Dec  6 00:11:43 pbx sendmail[4336]: pB65Bhqf004336: from=root, size=14, class=0, nrcpts=1, msgid=<201112060511.pB65Bhqf004336@pbx.local>, relay=root@localhost
Dec  6 00:11:43 pbx sendmail[4337]: pB65Bhtv004337: from=<root@pbx.local>, size=278, class=0, nrcpts=1, msgid=<201112060511.pB65Bhqf004336@pbx.local>, proto=ESMTP, daemon=MTA, relay=pbx.local [127.0.0.1]
Dec  6 00:11:43 pbx sendmail[4336]: pB65Bhqf004336: to=bergey@thebergeys.com, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30014, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (pB65Bhtv004337 Message accepted for delivery)
Dec  6 18:44:13 pbx sendmail[4361]: pB6NiBuN004361: from=root, size=450, class=0, nrcpts=1, msgid=<201112062344.pB6NiBuN004361@pbx.local>, relay=root@localhost
Dec  6 18:44:13 pbx sendmail[4364]: pB6NiD3M004364: from=<root@pbx.local>, size=679, class=0, nrcpts=1, msgid=<201112062344.pB6NiBuN004361@pbx.local>, proto=ESMTP, daemon=MTA, relay=pbx.local [127.0.0.1]
Dec  6 18:44:13 pbx sendmail[4361]: pB6NiBuN004361: to=root, ctladdr=root (0/0), delay=00:00:02, xdelay=00:00:00, mailer=relay, pri=30450, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (pB6NiD3M004364 Message accepted for delivery)
Dec  6 18:44:13 pbx sendmail[4365]: pB6NiD3M004364: to=<root@pbx.local>, ctladdr=<root@pbx.local> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30860, dsn=2.0.0, stat=Sent
Dec  6 18:44:26 pbx sendmail[4411]: pB6NiP7i004411: from=root, size=14, class=0, nrcpts=1, msgid=<201112062344.pB6NiP7i004411@pbx.local>, relay=root@localhost
Dec  6 18:44:27 pbx sendmail[4426]: pB6NiQ9D004426: from=<root@pbx.local>, size=278, class=0, nrcpts=1, msgid=<201112062344.pB6NiP7i004411@pbx.local>, proto=ESMTP, daemon=MTA, relay=pbx.local [127.0.0.1]
Dec  6 18:44:27 pbx sendmail[4411]: pB6NiP7i004411: to=bergey@thebergeys.com, ctladdr=root (0/0), delay=00:00:02, xdelay=00:00:01, mailer=relay, pri=30014, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (pB6NiQ9D004426 Message accepted for delivery)

Author

Commented:
Correct..  You are looking at the server I am trying to relay from NOT the sendmail I am configuring.

I am trying to use my linux server that is moved to different locations to relay to mail.thebergeys.com and send the mail using  the test account
test@thebergeys.com

I see, okay.

The log file on your system says:

Dec  6 18:44:27 pbx sendmail[4411]: pB6NiP7i004411: to=bergey@thebergeys.com, ctladdr=root (0/0), delay=00:00:02, xdelay=00:00:01, mailer=relay, pri=30014, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (pB6NiQ9D004426 Message accepted for delivery)

But I'm betting the mail doesn't actually arrive at bergey@thebergeys.com right?  That looks like a local delivery, and the mail is probably ending up in /var/spool/mail/bergey on server pbx, yes?  My thought is that the Linux box you are using thinks that IT is thebergeys.com, which is wrong - what does it say in /etc/mail/local-host-names?  If thebergeys.com is in there, remove it, and restart sendmail.

Try a test email to a gmail or hotmail account too, and show me what the log says for that.

Author

Commented:
root@pbx:/var/log $ cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               pbx.local pbx localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
root@pbx:/var/log $



Dec  6 18:57:44 pbx sendmail[4542]: pB6NviGN004542: from=root, size=14, class=0, nrcpts=1, msgid=<201112062357.pB6NviGN004542@pbx.local>, relay=root@localhost
Dec  6 18:57:44 pbx sendmail[4543]: pB6NvilW004543: from=<root@pbx.local>, size=276, class=0, nrcpts=1, msgid=<201112062357.pB6NviGN004542@pbx.local>, proto=ESMTP, daemon=MTA, relay=pbx.local [127.0.0.1]
Dec  6 18:57:44 pbx sendmail[4542]: pB6NviGN004542: to=lbergey01@gmail.com, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30014, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (pB6NvilW004543 Message accepted for delivery)

Author

Commented:
FYI.  No there is not /var/spool/mail/lbergey
Those logs don't look accurate then.  It should look something like this:

Dec  6 18:06:06 myserver sendmail[29065]: pB7066em029065: from=xterm, size=224, class=0, nrcpts=1, msgid=<201112070006.pB7066em029065@myserver.com>, relay=xterm@localhost
Dec  6 18:06:06 myserver sendmail[29067]: pB7066ss029067: from=<xterm@myserver.com>, size=466, class=0, nrcpts=1, msgid=<201112070006.pB7066em029065@myserver.com>, proto=ESMTP, daemon=MTA, relay=myserver.com [127.0.0.1]
Dec  6 18:06:06 myserver sendmail[29065]: pB7066em029065: to=myemail@gmail.com, ctladdr=xterm (1000/100), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30224, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (pB7066ss029067 Message accepted for delivery)
Dec  6 18:06:07 myserver sendmail[29069]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=RC4-SHA, bits=128/128
Dec  6 18:06:08 myserver sendmail[29069]: pB7066ss029067: to=<myemail@gmail.com>, ctladdr=<xterm@myserver.com> (1000/100), delay=00:00:02, xdelay=00:00:01, mailer=esmtp, pri=120466, relay=gmail-smtp-in.l.google.com. [74.125.47.26], dsn=2.0.0, stat=Sent (OK 1323216367 s21si7447817yhm.100)

The last line should have the IP of the server it's arriving at, not 127.0.0.1.  What is the output of the command "mailq"?

ARE YOU RECEIVING THE MESSAGES AT THOSE TWO ADDRESSES?
I asked you for "/etc/mail/local-host-names" not "/etc/hosts"

Author

Commented:
Different File.....

Same Results...



root@pbx:/etc/mail $ cat local-host-names
# local-host-names - include all aliases for your machine here.
root@pbx:/etc/mail $

Author

Commented:
root@pbx:/etc/mail $ mailq
                /var/spool/mqueue (14 requests)
-----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient-----------
pB6NvilW004543        0 Tue Dec  6 18:57 <root@pbx.local>
                 (Deferred: Connection timed out with thebergeys.com.bak-mx.na)
                                         <lbergey01@gmail.com>
pB64UmK8003671       13 Mon Dec  5 23:30 <root@pbx.local>
                 (Warning: could not send message for past 4 hours)
                                         <bergey@thebergeys.com>
pB6NiQ9D004426        0 Tue Dec  6 18:44 <root@pbx.local>
                 (Deferred: Connection timed out with thebergeys.com.bak-mx.na)
                                         <bergey@thebergeys.com>
pB65Bhtv004337        0 Tue Dec  6 00:11 <root@pbx.local>
                 (Deferred: Connection timed out with thebergeys.com.bak-mx.na)
                                         <bergey@thebergeys.com>
pB64DJFm002083       13 Mon Dec  5 23:13 <root@pbx.local>
                 (Warning: could not send message for past 4 hours)
                                         <bergey@thebergeys.com>
pB64EaGF002133       13 Mon Dec  5 23:14 <root@pbx.local>
                 (Warning: could not send message for past 4 hours)
                                         <bergey@thebergeys.com>
pB64CnxA002038       13 Mon Dec  5 23:12 <root@pbx.local>
                 (Warning: could not send message for past 4 hours)
                                         <bergey@thebergeys.com>
pB64KpcV003223        0 Mon Dec  5 23:20 <root@pbx.local>
                 (Warning: could not send message for past 4 hours)
                                         <bergey@thebergeys.com>
pB63niG1001794       13 Mon Dec  5 22:49 <root@pbx.local>
                 (Warning: could not send message for past 4 hours)
                                         <bergey@thebergeys.com>
pB638X5R001292       13 Mon Dec  5 22:08 <root@pbx.local>
                 (Warning: could not send message for past 4 hours)
                                         <bergey@thebergeys.com>
pB639Ll5001333       13 Mon Dec  5 22:09 <root@pbx.local>
                 (Warning: could not send message for past 4 hours)
                                         <bergey@thebergeys.com>
pB632WxN001179       13 Mon Dec  5 22:02 <root@pbx.local>
                 (Warning: could not send message for past 4 hours)
                                         <bergey@thebergeys.com>
pB630EqS001117       13 Mon Dec  5 22:00 <root@pbx.local>
                 (Warning: could not send message for past 4 hours)
                                         <bergey@thebergeys.com>
pB5L9cXe004373    13393 Mon Dec  5 16:09 <asterisk@pbx.local>
                 (Deferred: Connection timed out with thebergeys.com.bak-mx.na)
                                         <bergey@thebergeys.com>
                Total requests: 14
root@pbx:/etc/mail $

Going to ask one last time, are the test emails arriving at lbergey01@gmail.com and bergey@thebergeys.com after you see those logs?

Author

Commented:
It looks like sendmail is trying to deliver the mail directly, not relay it to my external server.
Okay, I see that they are not - they are all trapped in the mail queue, nothing is actually being sent.

Please show me:
cat /var/spool/mqueue/qfpB6NvilW004543

Open in new window

Author

Commented:
No.  That is the whole issue.  The problem is Verizon blocks port 25 and I can't send.  If I connect to a network that does not block port 25 sendmail works fine and I receive my messages.  The whole reason for the relay is the blocked port.

Author

Commented:
root@pbx:/etc/mail $ cat /var/spool/mqueue/qfpB6NvilW004543
V8
T1323215864
K1323216105
N1
P120276
I3/66/163020
MDeferred: Connection timed out with thebergeys.com.bak-mx.na0106.smtpbak.com.
Fs
$_pbx.local [127.0.0.1]
$rESMTP
$spbx.local
${daemon_flags}
${if_addr}127.0.0.1
S<root@pbx.local>
MDeferred: Connection timed out with thebergeys.com.bak-mx.na0106.smtpbak.com.
rRFC822; lbergey01@gmail.com
RPFD:<lbergey01@gmail.com>
H?P?Return-Path: <?g>
H??Received: from pbx.local (pbx.local [127.0.0.1])
        by pbx.local (8.13.8/8.13.8) with ESMTP id pB6NvilW004543
        for <lbergey01@gmail.com>; Tue, 6 Dec 2011 18:57:44 -0500
H?x?Full-Name: root
H??Received: (from root@localhost)
        by pbx.local (8.13.8/8.13.8/Submit) id pB6NviGN004542
        for lbergey01@gmail.com; Tue, 6 Dec 2011 18:57:44 -0500
H??Date: Tue, 6 Dec 2011 18:57:44 -0500
H??From: root <root@pbx.local>
H??Message-Id: <201112062357.pB6NviGN004542@pbx.local>
H??Subject: Test
.
root@pbx:/etc/mail $
That is okay, port 25 won't matter when we get this set up correctly, because it should be connecting to mail.thebergeys.com on port 2626 in order to send, not going directly to the MX record of the destination on port 25.

You can delete all the messages in /var/spool/mqueue now - we do not need them anymore.  I just need to figure out why your system isn't honoring the DS line in /etc/mail/sendmail.cf

I will get back to you shortly.

Author

Commented:
I just increased the point value, so you get more points for all of the time you are putting into this.  Thanks.

Author

Commented:
Thanks a lot.  I spent some time trying a number of things and finally got it working.
Excellent!  Can you tell me what you fixed to get it working in case I have to help other people with similar issues?

Author

Commented:
I was trying a number of things  I don't know if it was just one or a number of things.  I will try to go back over it later so I have for future reference as well, but I was pressed to get it running for a demo tomorrow night.   Thanks again.  I will try to reconfigure and restest.