Sendmail & SMTP

I have searched this forum extensively and can't seem to find a workable solution to my sendmail issue, but that could be down to my own lack of knowledge so please bear with me...

I am using a Sun Solaris 9 box to try and send e-mail to external addresses. The Unix box is not an e-mail server. Our e-mail is done through a third party ISP i.e. POP3 accounts, complete with user names and passwords.

I'm using sendmail version 8.12.2+Sun and I have made a number of changes (rightly or wrongly) to /etc/mail/sendmail.cf & /etc/init.d/sendmail based on details found on www.kempston.net.

The problem I'm having is this.

When I send a mail to my external address the mail is queued, I can see it in mailq, but it never gets sent.

I can telnet onto port 25 and can see sendmail is running.

I can also see send mail running when I us "ps".

root 5392 1 0 12:13:45 ? 0:00 /usr/lib/sendmail -bd -X /var/log/mail.log -oL9
smmsp 5393 1 0 12:13:45 ? 0:00 /usr/lib/sendmail -Ac -q15m

NOTE: I edited /etc/init.d/sendmail to add the "-X /var/log/mail.log" line ...

The changes to the /etc/mail/sendmail.cf are as follows:

! # "Smart" relay host (may be null)
! DSmailhost$?m.$m$.

Changed to read.....

! # "Smart" relay host (may be null)
! DSmail.mailhost.com

Where mail.mailhost.com is the SMTP server.

! # avoid connecting to "expensive" mailers on initial submission?
! O HoldExpensive=False

Changed to read ......

! # avoid connecting to "expensive" mailers on initial submission?
! O HoldExpensive=True

Added in an entry to read ......

  • # Don't Use DNS
  • O ResolverOptions=-DNSRCH

Also changed line .....

! Mrelay, P=[IPC], F=mDFMuXa8, S=EnvFromSMTP/HdrFromSMTP, R=MasqSMTP, E=\r\n, L=2040,

Added in "e" after "F=".....

! Mrelay, P=[IPC], F=emDFMuXa8, S=EnvFromSMTP/HdrFromSMTP, R=MasqSMTP, E=\r\n, L=2040,

And also added in rule S11 ....

Where me@domain.com is my actual e-mail address .....

I have also edited the /etc/hosts file to include:

xxx.xxx.x.x servername servername.domain loghost

Where the domain part is the text after the @ of my mail address, the IP is local.

And also added

xxx.xx.xx.x mail.mymailhost.com mailhost

Where the mymailhost is the SMTP server and the IP is the primary DNS IP

When I run the following command:

/usr/lib/sendmail -d0.1 -bt < /dev/null

I get the following output ...

# /usr/lib/sendmail -d0.1 -bt < /dev/null
Version 8.12.2+Sun
Compiled with: DNSMAP LDAPMAP LOG MAP_REGEX MATCHGECOS MILTER MIME7TO8 MIME8TO7 NAMED_BIND NDBM NETINET NETINET6 NETUNIX NEWDB NIS NISPLUS PIPELINING SCANF USERDB XDEBUG

============ SYSTEM IDENTITY (after readcf) ============
(short domain name) $w = servername
(canonical domain name) $j = servername.domain
(subdomain name) $m = domain
(node name) $k = servername

ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>

I have been testing this with the following simple script:

# more send_mail

SUBJ="Send mail from Unix with file attachments"
TO=me@domain.com
(
cat << !
To : ${TO}
Subject : ${SUBJ}
!

cat << !
HOPE THIS WORKS
you got the mail from sendmail utility
!

uuencode test.txt test.txt

) | /usr/lib/sendmail -v ${TO} ${CC}
#

Which produces the following output:

me@domain.com... Connecting to localhost via relay...
220 servername.domain ESMTP Sendmail 8.12.2+Sun/8.12.2; Tue, 9 Jan 2007 14:30:09 GMT
>>> EHLO servername.domain
250-servername.domain Hello localhost [xxx.x.x.x], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-EXPN
250-VERB
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-DELIVERBY
250 HELP
>>> MAIL From:<me@servername.domain> SIZE=194
250 2.1.0 <me@servername.domain>... Sender ok
>>> RCPT To:<me@domain.com>
>>> DATA
250 2.1.5 <me@domain.com>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
250 2.0.0 l09EU9aE007093 Message accepted for delivery
me@comain.com... Sent (l09EU9aE007093 Message accepted for delivery)
Closing connection to localhost
>>> QUIT
221 2.0.0 servername.domain closing connection

The mailq produces the following:

# mailq
/var/spool/mqueue (1 request)
-----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient-----------
l09EU9aE007093 122 Tue Jan 9 14:30 <me@servername.domain>
<me@domain.com>
Total requests: 1
#

The log file /var/log/mail.log looks like this:

# more mail.log

07093 >>> 220 servername.domain ESMTP Sendmail 8.12.2+Sun/8.12.2; Tue, 9 Jan 2007 14:30:
09 GMT
07093 <<< EHLO servername.domain
07093 >>> 250-servername.domain Hello localhost [xxx.x.x.x], pleased to meet you
07093 >>> 250-ENHANCEDSTATUSCODES
07093 >>> 250-PIPELINING
07093 >>> 250-EXPN
07093 >>> 250-VERB
07093 >>> 250-8BITMIME
07093 >>> 250-SIZE
07093 >>> 250-DSN
07093 >>> 250-ETRN
07093 >>> 250-DELIVERBY
07093 >>> 250 HELP
07093 <<< MAIL From:<me@servername.domain> SIZE=194
07093 >>> 250 2.1.0 <me@servername.domain>... Sender ok
07093 <<< RCPT To:<me@domain.com>
07093 >>> 250 2.1.5 <me@domain.com>... Recipient ok
07093 <<< DATA
07093 >>> 354 Enter mail, end with "." on a line by itself
07093 <<< Received: (from root@localhost)
07093 <<< by servername.domain (8.12.2+Sun/8.12.2/Submit) id l09EU9h8007089
07093 <<< for me@domain.com; Tue, 9 Jan 2007 14:30:09 GMT
07093 <<< Date: Tue, 9 Jan 2007 14:30:09 GMT
07093 <<< From: me@servername.domain
07093 <<< Message-Id: <200701091430.l09EU9h8007089@servername.domain>
07093 <<< To: me@domain.com
07093 <<< Subject: Send mail from Unix with file attachments
07093 <<<
07093 <<< HOPE THIS WORKS
07093 <<< you got the mail from sendmail utility
07093 <<< begin 444 test.txt
07093 <<< >5&AI<R!I<R!A('1E<W0@;6%I;"!F<F]M($ME;BX*
07093 <<<
07093 <<< end
07093 <<< .
07093 >>> 250 2.0.0 l09EU9aE007093 Message accepted for delivery
07093 <<< QUIT
07093 >>> 221 2.0.0 servername.domain closing connection

I can see the message in queued in /var/spool/mqueue

So why is it not reaching the destination e-mail account?

What am I missing?

In your post above you stated :

From what I see, there are no errors, or wrong configs, if I'm wrong, please correct me.
If the above is true, is this mail being sent to another SMTP for outgoing delivery ? If yes, you may check with the ISP. Otherwise i'm out of suggestions...for now...Eventhough you've provided every piece of information that you can obtain.
Idea : can you send mails locally ? like "mail postmaster@your-domain.com" or mailx ?

Thanks for the reply sysgate.

We do not have an e-mail server on site. All mails are handled via an ISP in this case netsource.ie. Mails come in via POP3 and are directed from the PC's to the outside world via SMTP, through a firewall and router. The mail server is mail.netsource.ie.

I'm not interested in taking mail in, I'm trying to send mail out.

Does that make it any easier?

It seems as though I'm missing a vital stage in this thing. It looks like the mails are being generated and queued okay but then hit a brick wall i.e. can't access the outside world.

Actually I've just noticed ...

me@domain.com... Connecting to localhost via relay...

Should that not be connecting to the mailhost?

If so what do I need to change to get it to use the mailhost instead of the localhost?

Cheers...

uh, it really depends....The strangest thing is that you don't receive any errors, so that we can trooubleshoot and give some suggestions...
This "Connecting to localhost via relay" I had fixed with another trick a while ago, with making a symbolic link between "sendmail.cf" and "submit.cf", but the error message was different. In your case I would ask you to check for relevant info in your .mc file : at the bottom there should be two lines :
MAILER(local) and MAILER(smtp). Also you may check in your source files for any obvious errors, and alternatively, try to rebuild the sendmail using macros options. The other thing is the ISP's mail server, can you ask them for more logs ? Did you try other mail recepients where you can verify for sure that your mail is not being received ? Otherwise I'm afraid I'm out of ideas for now, but I'm willing to help with mail issues, knowing my bitter experience when started administering mail servers few years ago.

I's been a long time since I last dealt with sendmail, but I rememeber a couple of things that might help you to "find the path" :slight_smile:
The problem, to me, is either of these:

  • Your ISP mail server has to accept that you use it as "relay host", or
  • Your ISP mail server needs authentication.
    I would try to focus on the second one...
    Regads.

Hi Guys,

After much scratching of head I edited the /etc/mail/submit.cf file and changed the default MTA host from localhost to mailhost.

Changed from:

D{MTAHost}localhost

To ....

D{MTAHost}mailhost

I tried my script again and this time while it does appear to be trying to connect to the mailhost it is throwing up some new messages.

me@domain.ie... Connecting to mailhost via relay...
220 gran.netsource.ie ESMTP Spammers are not welcome here! Wed, 10 Jan 2007 11:34:10 +0000
>>> EHLO servername.domain
250-gran.netsource.ie Hello servername.domain [xxx.xx.xx.x]
250-SIZE 62914560
250-PIPELINING
250 HELP
>>> MAIL From:<root@servername.domain> SIZE=194
250 <root@servername.domain> is syntactically correct
>>> RCPT To:<me@domain.ie>
>>> DATA
250 <me@domain.ie> verified
354 Enter message, ending with "." on a line by itself
>>> .
550-Could not verify sender
550 rejected: cannot route to sender <root@servername.domain>
>>> RSET
250 Reset OK
root... Using cached ESMTP connection to mailhost via relay...
>>> MAIL From:<> SIZE=1218
250 <> is syntactically correct
>>> RCPT To:<root@servername.domain>
>>> DATA
550 Cannot route to <root@servername.domain>
503 Valid RCPT TO <recipient> must precede DATA
>>> RSET
250 Reset OK
>>> RSET
250 Reset OK
postmaster... Using cached ESMTP connection to mailhost via relay...
>>> MAIL From:<> SIZE=2242
250 <> is syntactically correct
>>> RCPT To:<postmaster@servername.domain>
>>> DATA
550 Cannot route to <postmaster@servername.domain>
503 Valid RCPT TO <recipient> must precede DATA
>>> RSET
250 Reset OK
Jan 10 11:36:39 servername sendmail[6017]: [ID 801593 mail.alert] l0ABabrN006017: Losing ./qfl0ABabrN006017: savemail panic
Closing connection to mailhost
>>> QUIT
221 gran.netsource.ie closing connection

Any ideas on where to go from here?

Cheers muckers ....

Here it is. gran.netsource.ie, which I suppose is yout ISP's MTA, is not accepting mails from root@servername.domain. That's correct. You have to "rewrite" it to a something that gran.netsource.ie accepts. Or, if you prefer, map users :). I've found this website, that may be interesting for you:
http://www.leg.uct.ac.za/Articles/sendmail_dialup.html
Regards.

Okay, I seem to be making progress now.

I tested sendmail with the following command:

/usr/lib/sendmail -f myaddress@domain.ie myaddress@domain.ie < test.txt

And low and behold I got the e-mail through to outlook on my PC.

Now I've been looking at trying to masquerade the host name so instead of it sending from root@servername.domain trying to get it to masquerade as domain.ie.

To do this I added the following line to the /etc/mail/sendmail.cf file:

# Who I masquerade as ( null for no masquerading) (see also $=M)
DMdomain.ie

I added it because it wasn't there.

Sendmail seems to be ignoring the DM directive, any ideas?

Plus I have been editing the config files directly i.e. not using the M4 macro, does this make me mental?

Remember that you have also to map usernames in case they're not the same (local/remote), which I think is your case (root != myaddress). On the link I posted before it's explained.