[plug] fetchmail alternative
Andrew Francis
lists at sullust.net
Sat Jul 27 01:22:14 WST 2002
On Sat, Jul 27, 2002 at 12:12:02AM +0800, Bernard Blackham wrote:
> 2) A daemon starts up on my machine listening on a certain port
> for connections from the notification daemons running on other
> machines actually receiving mail
It sounds like what you're proposing is that when mail arrives, the mail
server taps your laptop on the shoulder, then the laptop runs fetchmail.
Fetchmail can forward stuff to an arbitrary SMTP server, so you should
be able to do this in one fell swoop - have your laptop listen for mail
on port 25, and mail servers forward mail to it when it arrives.
I would suggest having your laptop make sure that, for example,
http://blackham.com.au/~bernard/laptopip.txt always contained
the IP of your laptop. Given the laptop's IP, the easiest, most secure
way of doing this (and hands-free if you're using ssh-agent):
echo $MY_IP_ADDRESS | ssh bernard at blackham.com.au "cat - > public_html/laptopip.txt"
Then, on any mailservers that you wanted to
forward mail, you could do the following every 5 minutes or so
(rough sketch only :)
# get laptop's ip address
LAPTOPIP=`curl http://blackham.com.au/~bernard/laptopip.txt`
# make sure this worked okay, and we have a valid IP address
# .... too lazy to write ....
# if so, get fetchmail to grab mail from the POP server on this
# mailserver, and forward it to the SMTP server on my laptop
fetchmail -p POP3 --smtpuser my_laptop_username --smtphost $LAPTOPIP localhost
A paranoid twist on the above (you don't want to send your mail to a machine
that isn't actually your laptop!) would be to tunnel over an authenticated
connection. SSH with strict host key checking (set in /etc/ssh/ssh_config
or ~/.ssh/config, IIRC) should do the job. Keep in mind that you don't
need to do this with the user that will eventually receive the mail, so
you should be able to leave an unpassworded key around to authenticate.
Something like this:
# forward local port 2525 to laptop's port 25. no remote command
ssh -C -2 -N -L 2525:localhost:25 -l nobodymail $LAPTOPIP &
SSH_PID=$!
# wait a few seconds so that the connection can be established.
# dirty hack
sleep 10
# run fetchmail, just like before, but over encrypted tunnel
fetchmail -p POP3 --smtpuser my_laptop_username --smtphost localhost/2525 localhost
# kill the ssh session
kill $SSH_PID
This stuff was obviously written at 1am; my apologies :)
--
Andrew Francis | To email me, get | ASCII ribbon campaign ( )
Perth, Australia | the real address | against HTML email X
http://www.sullust.net/ | from my homepage | http://arc.pasp.de/ / \
More information about the plug
mailing list