Re: using a remote IMAP server and smarthost
On Sun, Aug 26, 2007 at 11:06:14 +0100, Richard Lyons wrote:
> On Sat, August 25, 2007 23:27, Florian Kulzer wrote:
> > In the following I will assume that your ~/.ssh/config is set up such
> > that you can use "ssh myvm" to log in on the vm. (This allows me to keep
> > the command syntax simple and in any case I think it is a good approach
> > in practice.) I would also recommend to set up public key authentication
> I have set up the alias for ssh, and created a key for authentication.
> > and to use ssh-agent, to avoid having to type your password whenever you
> > send mail.
> I read the man page for ssh-agent, but am not much the wiser. Still, I
> figure I can try without it for now...
We can tackle this later. You can set an empty passphrase for your
private key for now, so that it does not bother you while you experiment
with mail via ssh.
> > Method 1:
> > ---------
> > You can forward a local port via ssh like this:
> > ssh -N -L 2525:smtp.smarthost.tld:25 myvm
> > This command establishes an ssh connection to myvm. Everything that is
> > sent to port 2525 on your local computer will be forwarded to myvm and
> > then myvm will pass it on to smtp.smarthost.tld, port 25. This is like a
> > mini-VPN for only one port; you have to run this command before you send
> > mail(s) and you can cancel it (CTRL-C) when you are done. Mutt (or any
> > other MUA) on the local computer can now simply be configured to use
> > localhost, port 2525 as its smtp server.
> I find the whole mail process absurdly confusing, and nobody seems to
> have written a lucid explanation of how the bits fit together. I read
> mail by connecting to the IMAP server. When I write mail, mutt sends
> it to my local sendmail, is that right? And the local sendmail is
> specified in ~/.muttrc thus:
> set sendmail="/usr/lib/sendmail"
> which is really my local exim4. So that needs to be set up to send via
> port 2525. How?
> Or is that all wrong?
That is all correct. However, I vaguely remember that I had difficulties
in the past when I tried to get exim4 to work over a forwarded port. The
most straightforward approach is to run "dpkg-reconfigure exim4-config"
and select "local delivery only" (for system mails from cronjobs, etc.).
Then you can either use mutt's built-in smtp mechanism (exists in Lenny
and Sid, but not in Etch, I think) or you can install the "msmtp"
package which provides a sendmail work-alike that is very easy to
configure. Here is an example configuration file (~/.msmtprc):
Then you can tell mutt to use msmtp by putting
into your ~/.muttrc and you should be ready to go.
Of course, it would be even more interesting if you could install and
configure msmtp on your VM (using the smarthost of your provider
directly in .msmtprc). If this works with mutt running on the VM then it
should be possible to use "method 2" of my previous mail for your local
mutt by changing the command in the wrapper script to:
cat - | ssh myvm "/usr/bin/msmtp $@"
Regards, | http://users.icfo.es/Florian.Kulzer