On Mon, 2008-04-21 at 14:37 +1000, Mary Gardiner wrote: > I wasn't clear in my original mail: I'm more interested in how people > get their laptop to switch mail settings between "inside horrible > network" and "normal operation" than I am in specifically what their > inside-horrible-network settings are, because in this particular case I > can use the university's mail server to get mail out (and I also have an > SSH server on my own machine listening on 443, so if I couldn't I could > do various SSH tunneling). It's just annoying to have to remember to > re-configure my mail client (in this case, actually Postfix, but similar > problems apply to any client, whether full MTA or not) when I am located > at uni, and again when I leave.
Using postconf -e An example script (probably broken) that I used to run on my laptop: if (( `id -u` != 0 )); then { echo "Sorry, must be root. Exiting..."; exit; } fi postconf -e "defer_transports = " postconf -e "relayhost = " postconf -e "transport_maps = " # check if eth0 not up - send email later (TODO: handle ppp0 for evdo) myip=`ip a sh eth0 | grep 'inet\>'` if [ -z "$myip" ] ; then postconf -e "defer_transports = smtp" postfix reload postfix flush exit 0 fi # if we're at home, send email instantly using sandia as relay myip=`ip a sh eth0 | grep 'inet\>' | awk '{print $2}'` if [ $myip = "192.168.1.1/24" ] ; then postconf -e "relayhost = [192.168.1.254]:25" postfix reload postfix flush exit 0 fi # if we're on didata staff network, relay POE email via sydmta.POE.com.au myip=`ip a sh eth0 | grep 'inet\>'| awk '{print $2}' | awk -F. '{print $1 "." $2}'` if [ $myip = "148.182" ] ; then postconf -e "relayhost = [sydmta.POE.com.au]:25" # TODO: work out bug in transport map & combine with ssh tunnel #postconf -e "transport_maps = hash:/etc/postfix/transport" postfix reload postfix flush exit 0 fi # otherwise, just defer transport (until I implement ssh tunnel) # including 10.172.x.y addresses (when on classroom net) - can't relay via sydmta postconf -e "defer_transports = smtp" postfix reload postfix flush exit 0 # TODO bring up ssh tunnel # otherwise, just use ssh tunnel #postconf -e "relayhost = [127.0.0.1]:2525" #postfix reload #postfix flush #exit 0 -- Thanks, Sonia Hamilton http://soniahamilton.wordpress.com http://www.linkedin.com/in/soniahamilton -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html