On 12Sep2021 15:17, Globe Trotter via Mutt-users <[email protected]> wrote:
>So, I do not know if I can do this, but I can send email by
>specifically including the smtp with port 25. I dont really need it for
>anything else. It is quite likely that I am not understanding the
>import of your question.
>
>All I do is:
>
>sudo ssh -L 25:mailhub:25 username@your_server
>
>And then, configuring 'localhost' as my smtp server on port 25 gets my
>mail sent directly forward through the SSH link.
Ok, so you're running the ssh connection as root. That's usually a bad
idea. The only reason you need to do that that I can see above is to
bind to port 25 at the local end. I would recommend running your tunnel
like this:
ssh -L 1025:mailhub:25 username@your_server
and configuring your mutt smtp_url to use port 1025 instead of 25.
Others have made this same suggestion.
IMO, it is also worth configuring your local postfix install, provided
postfix is active locally. Particularly if this is your normal machine
which you usually use - having a working local mail system is a good
thing - lots of things send email, such as cron and at - they will all
just start working if you set this up.
This means that you can compose and "send" (well, queue) email locally
when offline or when the ssh tunnel is not up. It will go out next time
the tunnel's up. Then you just turn off the smtp_url setting and use
the local sendmail command for delivery. That's what I do.
Most of postfix's configuration is in the file /etc/postfix/main.cf
In particular you want (taken from my own main.cf file here):
relayhost = 127.0.0.2:1025
mydomain = cskk.id.au
myorigin = cskk.id.au
mydestination = $myhostname, localhost.$mydomain, localhost
inet_interfaces = localhost
mynetworks_style = host
Obviously change:
- cskk.id.au to your own domain - you want the local email system to
send legitmate headers.
- relayhost to be your ssh tunnel: localhost:1025
Relayhost is the upstream smarthost which accepts your email. It is the
equivalent of the smtp_url in the mutt config, but having postfix do
that bit. It can of course be an ISP etc; for example one of the (many)
commented out ones I've got here is:
##relayhost = mail.optusnet.com.au
which was there to deliver directly to a former ISP. My 127.0.0.2 is
part of my local setup: I've got haproxy running there, to deliver to
whatever upstream ISP is available - in my case the home server or an
ssh tunnel to our cloud VM, both of which have their own postfix setups.
Cheers,
Cameron Simpson <[email protected]>