Thursday 3 April 2008

library-check.pl, postfix config to forward/relay mail to smtp server

1. Move across library-check.pl script from suse to ubuntu
2. enable mail from command-line and perl WWW::Mechanize script dependancies
3. solve postfix trouble (i.e. config postfix properly)
4. WAH! 5 + 6 books two accounts 5*23 + 6*29 days overdue. oops.


# Helpful reading:
Relaying Mail to a SMTP Server That Requires Authentication (Ubuntu/Postfix)
http://www.finefrog.com/2008/02/15/relaying-mail-to-a-smtp-server-that-requires-authentication-ubuntupostfix/
http://www.marksanborn.net/linux/send-mail-postfix-through-gmails-smtp-on-a-ubuntu-lts-server/
http://ubuntuforums.org/archive/index.php/t-67397.html
http://www.wormbytes.ca/articles/postfix-with-sympatico-relay
http://www.postfix.org/docs.html


O=/mnt/suseold
export http_proxy=
export https_proxy=
sudo apt-get install mailutils
sudo cpan -i WWW::Mechanize
sudo cp $O/usr/local/bin/library-check.pl /usr/local/bin/
sudo cp $O/etc/cron.daily/run_library-check.sh /etc/cron.daily/
sudo cp $O/etc/cron.daily/run_library-check-fionnuala.sh /etc/cron.daily/


# postfix setup took me a couple of hours - arg!
# simple postfix setup just to forward/relay mail to smtp server (which needs authentication)
# set some vars for use just in commands below
MYSMTPSERVER=www.smtpservername.com
MYACCOUNT=myaccount
PASSWORD=password
MYACCOUNT_SERVER=smtpservername.com
MYEMAIL=${MYACCOUNT}@${MYACCOUNT_SERVER}

# this was the thing I did last which started everything working (and uncomment myorigin = /etc/mailname in /etc/postfix/main.cf):
echo $MYSMTPSERVER > /etc/mailname

sudo vim /etc/postfix/mail.cf

# uncomment this:
myorigin = /etc/mailname

# add relay host with location of passwd info
relayhost = [<MYSMTPSERVER>]

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
smtp_sasl_security_options = noanonymous

smtp_always_send_ehlo = yes
smtpd_sasl_local_domain =
smtp_sasl_tls_security_options = noanonymous

# comment this line out:
#myhostname = <MYACCOUNT_SERVER>


# store smtp authentication details for postfix use
sudo mkdir /etc/postfix/sasl/
echo "${MYSMTPSERVER} ${MYEMAIL}:${PASSWORD}" > /etc/postfix/sasl/sasl_passwd
postmap /etc/postfix/sasl/sasl_passwd
rm /etc/postfix/sasl/sasl_passwd # I think.
# but ACTUALLY I notice the hash did not seem to work? can still see info unhashed in /etc/postfix/sasl/sasl_passwd.db ?


/etc/init.d/postfix restart


# log of successful send:
tail -1550f /var/log/syslog |grep -v atkbd.c

Apr 4 02:08:29 <MYHOSTNAME> postfix/pickup[12695]: 6320E454092: uid=1000 from=<<MYACCOUNTNAME>>
Apr 4 02:08:29 <MYHOSTNAME> postfix/cleanup[12700]: 6320E454092: message-id=<20080404010829.6320E454092@<MYHOSTNAME>.localdomain>
Apr 4 02:08:29 <MYHOSTNAME> postfix/qmgr[12696]: 6320E454092: from=<<MYACCOUNTNAME>@<MYACCOUNT_SERVER>>, size=384, nrcpt=1 (queue active)
Apr 4 02:08:30 <MYHOSTNAME> postfix/smtp[12702]: 6320E454092: to=<<MYACCOUNTNAME>@<MYACCOUNT_SERVER>>, relay=<MYSMTPSERVER>[<MYSMTPHOSTIP>]:25, delay=1.2, delays=0.03/0.01/1.1/0.06, dsn=2.0.0, status=sent (250 OK id=1JhaPy-00073e-6f)
Apr 4 02:08:30 <MYHOSTNAME> postfix/qmgr[12696]: 6320E454092: removed



smtp auth failed
because smtp user is NOT <MYACCOUNTNAME>@<MYHOSTNAME>.localdomain
"550-Verification failed for <<MYACCOUNTNAME>@<MYHOSTNAME>.localdomain> 550-Unrouteable address"
This is solved by having smtp server name in: /etc/mailname

Apr 4 02:05:35 <MYHOSTNAME> postfix/pickup[12551]: 04E56454092: uid=1000 from=<<MYACCOUNTNAME>>
Apr 4 02:05:35 <MYHOSTNAME> postfix/cleanup[12556]: 04E56454092: message-id=<20080404010535.04E56454092@<MYHOSTNAME>.localdomain>
Apr 4 02:05:35 <MYHOSTNAME> postfix/qmgr[12552]: 04E56454092: from=<<MYACCOUNTNAME>@<MYHOSTNAME>.localdomain>, size=404, nrcpt=1 (queue active)
Apr 4 02:05:36 <MYHOSTNAME> postfix/smtp[12558]: 04E56454092: to=<<MYACCOUNTNAME>@<MYACCOUNT_SERVER>>, relay=<MYSMTPSERVER>[<MYSMTPHOSTIP>]:25, delay=1.2, delays=0.03/0.01/1.1/0.03, dsn=5.0.0, status=bounced (host <MYSMTPSERVER>[<MYSMTPHOSTIP>] said: 550-Verification failed for <<MYACCOUNTNAME>@<MYHOSTNAME>.localdomain> 550-Unrouteable address 550 Sender verify failed (in reply to RCPT TO command))
Apr 4 02:05:36 <MYHOSTNAME> postfix/cleanup[12556]: 2AB34454093: message-id=<20080404010536.2AB34454093@<MYHOSTNAME>.localdomain>
Apr 4 02:05:36 <MYHOSTNAME> postfix/bounce[12559]: 04E56454092: sender non-delivery notification: 2AB34454093
Apr 4 02:05:36 <MYHOSTNAME> postfix/qmgr[12552]: 2AB34454093: from=<>, size=2580, nrcpt=1 (queue active)
Apr 4 02:05:36 <MYHOSTNAME> postfix/qmgr[12552]: 04E56454092: removed
Apr 4 02:05:36 <MYHOSTNAME> postfix/local[12560]: 2AB34454093: to=<<MYACCOUNTNAME>@<MYHOSTNAME>.localdomain>, relay=local, delay=0.02, delays=0.01/0.01/0/0.01, dsn=2.0.0, status=sent (delivered to mailbox)
Apr 4 02:05:36 <MYHOSTNAME> postfix/qmgr[12552]: 2AB34454093: removed

No comments: