Page 1 of 1

Sendmail with SMTP AUTH

Posted: Mon Feb 20, 2012 4:36 pm
by cah
1. Sendmail with SMTP AUTH needs SASL (Cyrus SASL)

ftp://ftp.andrew.cmu.edu/pub/cyrus-mail ... .25.tar.gz

2. Cyrus SASL requires phclient.h which is from "nph - PH Client and Programming API"

http://www.feep.net/nph/

nph installation is straightforward:

Code: Select all

configure
make
make install
Cyrus SASL installation is somehow tricky.

"configure" went smoothly but "make" complained about conflict of MD5_CTX struct from /usr/sfw/include/openssl/evp.h (line 82-84). I had to temporarily remove those 3 lines and compiling moved on but stopped again asking for gssapi.h. I had to manually copy /usr/include/gssapi/gssapi.h to <PATH>/cyrus-sasl-2.1.25/include and then the compiling finally went through completely. "make install" went fine thereafter. sasl2 got installed into /usr/lib/ and /usr/include/.

03/30/2012 - CAH
When I was trying to compile this, it was complaining about a conflict of gethostname definition in lib/saslutil.c.
I had to disable the following line in it:

Code: Select all

//extern int gethostname(char *, int);
Then, it compiled fine.

Sendmail rebuild

This needs several steps to get it to work:

1. Create a "site.config.m4" file in "<sendmail_src>/devtools/Site" and add the following entries(may or may not need the bottom 2 lines, I don't need them on cahtoh01):

Code: Select all

APPENDDEF(`confENVDEF', `-DSASL=2')
APPENDDEF(`conf_sendmail_LIBS', `-lsasl2')
APPENDDEF(`confLIBDIRS', `-L/usr/local/lib')
APPENDDEF(`confINCDIRS', `-I/usr/local/include') 
2. Create authentication information file

Code: Select all

# mkdir -p /etc/mail/auth
# chmod 700 /etc/mail/auth
# vi /etc/mail/auth/client-info
AuthInfo:outgoing.verizon.net "U:cahtoh@verizon.net" "I:cahtoh@verizon.net" "P:c4ht0h"
# cd /etc/mail/auth
# makemap dbm client-info < client-info
# chmod 600 client-info*
3. Adding following lines (may not need TRUST_AUTH line) in sendmail.mc:

Code: Select all

define(`SMART_HOST',`outgoing.verizon.net')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN') dnl
dnl TRUST_AUTH_MECH(`LOGIN PLAIN DIGEST-MD5 CRAM-MD5')dnl
FEATURE(`authinfo',`dbm /etc/mail/auth/client-info')dnl
4. Create new sendmail.cf:

Code: Select all

m4 /etc/mail/sendmail.mc.8.14 > /etc/mail/sendmail.cf.8.14.5
5. Compare this new sendmail.cf with existing one.

6. Start sendmail

Code: Select all

# /etc/init.d/sendmail start
# /usr/lib/sendmail -bd -q15m (if it did not come up automatically)
7. Outgoing mail test

Code: Select all

%mail chang_an@yahoo.com
iiiire
.
Entries from /var/log/syslog:

Code: Select all

Feb 20 13:39:22 cahtoh01 sendmail[1584]: [ID 801593 mail.info] q1KLdM6m001584: from=cah, size=106, class=0, nrcpts=1, msgid=<201202202139.q1KLdM6m001584@cahtoh01.hsiao.net>, relay=root@localhost
Feb 20 13:39:22 cahtoh01 sendmail[1585]: [ID 801593 mail.info] q1KLdMVJ001585: from=<cah@cahtoh01.hsiao.net>, size=362, class=0, nrcpts=1, msgid=<201202202139.q1KLdM6m001584@cahtoh01.hsiao.net>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Feb 20 13:39:22 cahtoh01 sendmail[1584]: [ID 801593 mail.info] q1KLdM6m001584: to=chang_an@yahoo.com, ctladdr=cah (1001/14), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30106, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (q1KLdMVJ001585 Message accepted for delivery)
Feb 20 13:39:27 cahtoh01 sendmail[1587]: [ID 801593 mail.info] q1KLdMVJ001585: to=<chang_an@yahoo.com>, ctladdr=<cah@cahtoh01.hsiao.net> (1001/14), delay=00:00:05, xdelay=00:00:05, mailer=relay, pri=120362, relay=outgoing.verizon.net. [206.46.232.12], dsn=2.0.0, stat=Sent (Ok, envelope id 0LZP00DJJO5610J1@vms173005.mailsrvcs.net)
My yahoo account receives email!

8. Incoming mail test

reply from yahoo account and see following entries in /var/log/syslog:

Code: Select all

Feb 20 13:42:04 cahtoh01 sendmail[1588]: [ID 801593 mail.info] q1KLg38v001588: from=<chang_an@yahoo.com>, size=3934, class=0, nrcpts=1, msgid=<1329774100.19503.YahooMailNeo@web130105.mail.mud.yahoo.com>, proto=SMTP, daemon=MTA-v4, relay=nm12-vm0.bullet.mail.ne1.yahoo.com [98.138.91.51]
Feb 20 13:42:06 cahtoh01 sendmail[1589]: [ID 801593 mail.info] q1KLg38v001588: to=<cah@cahtoh01.hsiao.net>, delay=00:00:02, xdelay=00:00:02, mailer=local, pri=34167, dsn=2.0.0, stat=Sent
Checked /var/mail/cah and found the mail came in.

This is extremely important.
Why?
I can use the dynamic IP and run all servers at home without paying for the static IP!!
This may actually work!

Sendmail with SMTP AUTH - procedure doesn't work on solaris

Posted: Sun Feb 26, 2012 2:18 am
by cah
For some reason, Cyrus SASL has other errors in code and I don't want to debug so I cheated a little.

I just moved the compiled directory from cahtoh01 to hsiao.net and install from the compiled directory.

I had to install nph before I can rebuild sendmail.
After I rebuilt it, sendmail was complaining about deopen issue and I just moved over the binary sendmail (with SASL) to /usr/lib.
Then, I was able to restart sendmail and it seems to work.

Sendmail with SMTP AUTH on Solaris 11

Posted: Fri Mar 30, 2012 6:53 pm
by cah
I don't know why the bottom 2 lines were missing in devtools/Site/site.config.m4:

Code: Select all

dnl ### SASL2 support
APPENDDEF(`confENVDEF', `-DSASL=2')
APPENDDEF(`conf_sendmail_LIBS', `-lsasl2')
APPENDDEF(`confLIBDIRS', `-L/usr/local/lib')
APPENDDEF(`confINCDIRS', `-I/usr/local/include')
I had to add them manually again.

Other than this, the path to nph was wrong too.
Wrong:

Code: Select all

APPENDDEF(`confINCDIRS', `-I/opt/nph/include')
APPENDDEF(`confLIBDIRS', `-L/opt/nph/lib')
Changed to:

Code: Select all

APPENDDEF(`confINCDIRS', `-I/usr/local/include')
APPENDDEF(`confLIBDIRS', `-L/usr/local/lib')
All the Makefile files have the wrong path and therefore compilation failed.
I had to manually update every single Makefile so that compilation moves on.

Sendmail installation installs man pages to 3 directories that did not exist:

/usr/share/man/cat1
/usr/share/man/cat5
/usr/share/man/cat8

Created them manually and the installation went fine.

Sendmail with SMTP AUTH on Solaris 11

Posted: Fri Mar 30, 2012 8:18 pm
by cah
The SMF couldn't start the sendmail.
At first, it couldn't find libsasl2.so.2 and I had to create a symbolic link for it:

Code: Select all

%ls -l /usr/lib/libsasl2.so.2
lrwxrwxrwx   1 root     root          33 Mar 30 16:04 /usr/lib/libsasl2.so.2 -> /usr/local/lib/libsasl2.so.2.0.25
/etc/init.d/sendmail start would not start sendmail -bd -q15m and no error message was given in /var/svc/log/network-smtp:sendmail.log.

I searched with the exact error message but without any luck.

Code: Select all

[ Mar 30 16:58:57 Executing start method ("/lib/svc/method/smtp-sendmail start"). ]
Invalid operation mode l
I then used "solaris smf Invalid operation mode l" to search and found a post pointing out a key:
http://groups.google.com/group/comp.mai ... e?lnk=raot

I had to change from -bl to -bd and it worked!

-bl is for loopback only. The system is configured as local_only.
Need to change to other value.

smtp:sendmail local_only

Posted: Sun Apr 01, 2012 5:47 pm
by cah
I remember having the same issue when I was working on cahtoh01.

Code: Select all

%/usr/bin/svcprop -p config/local_only smtp
true
%svccfg -s svc:/network/smtp:sendmail setprop config/local_only=false
%/usr/bin/svcprop -p config/local_only smtp
true
Still showing true.

I then went into svccfg to check.

Code: Select all

%svccfg -s svc:/network/smtp:sendmail
svc:/network/smtp:sendmail> editprop
select svc:/network/smtp:sendmail

# Property group "config"
# delprop config
# addpg config application
# setprop config/include_info = boolean: false
# setprop config/path_to_sendmail_mc = astring:
# setprop config/value_authorization = astring: solaris.smf.value.sendmail
# setprop config/local_only = boolean: false
......
It had been set.
I then realized that I need to run svcadm refresh to read the new settings.

Code: Select all

%svcadm refresh network/smtp:sendmail
%/usr/bin/svcprop -p config/local_only smtp:sendmail
false
It finally changed to false and sendmail can be started/stopped properly from /etc/init.d/sendmail.