February 2008 Archives
Saturday, 09 February 2008, 19:14 CET
fetchmail via SSH tunnel
If you have SSH access to your mail server,
fetchmail can automatically create a secure
SSH tunnel through which to retrieve email. Use the preconnect
configuration option in ~/.fetchmailrc:
poll localhost service PORT with proto POP3
password "secretpass"
preconnect 'ssh -f -C -L localhost:PORT:localhost:REMOTEPORT
USERATHOST sleep 3 < /dev/null > /dev/null'
The preconnect option should be on a single line. Replace PORT,
REMOTEPORT, and USERATHOST with your own values.
- PORT
- The port number on your own desktop or laptop computer that fetchmail should connect to.
- REMOTEPORT
- The port on the mail server which we want to connect to. For a POP3 server it is port number 110.
- USERATHOST
- User name and hostname that SSH shall use to connect to the mail server. Example: username@my.mailserver.com
- sleep 3
- A command for SSH to run on the remote host. SSH will disconnect when the command has run. (sleep 3 gives fetchmail time to connect to the remote mail server. SSH will notice that the forwarded port is used and won't disconnect until fetchmail has finished.)