Ssh tunnel for sendmail

I'm going to go crazy trying to set up my system.

I have a laptop at home and a workstation at work. I use mutt and sendmail. I have a home Internet service provider, which is on many blacklists, so any email that I send from my laptop through my Internet service provider is often blocked by the recipient. I can use SSH for my workstation and use mutt there interactively, but it is slow and tedious. I download email from a production server to a laptop using fetchmail.

I tried to get the laptop to send mail through an email program using

ssh -L 25:workstation.work.com:25 workstation.work.com 

but it seems that sendmail cannot work when I do this. When I try to fetchmail from a workstation to a laptop, sendmail must work on the laptop so that mail is delivered locally on the laptop. When mail passes, it is rejected because the host name is not recognized. I tried changing the hostname in mutt. This does not seem to affect anything.

So, I am confused about how to configure mutt, sendmail and SSH on my laptop so that I can compose and send emails from my laptop so that they are delivered, but I also want to receive my emails from the server using fetchmail and deliver it locally.

Any help was appreciated.

+4
source share
2 answers

If you run this ssh tunnel, you cannot run sendmail locally, because otherwise it will listen on port 25, not your tunnel. And by default, fetchmail wants the local mail server to deliver, although you can configure it to be delivered to the mbox file directly if you want.

Instead, I run postfix on my laptop and configured it to deliver mail to localhost: 2526 using relayhost=[127.0.0.1]:2526 in /etc/postfix/main.cf. Then I run the ssh tunnel ssh ssh -N -L 2526:localhost:25 ptomblin@myserver , so when postfix is ​​sent it tunnels through the tunnel. And local mail clients, such as mutt and fetchmail, see the local mail server running on port 25 as they expect.

+7
source

Paul: your answer went into business! I was confused and had to specify -L 54321: localhost: 25 instead of -L 54321: remotehost: 25. Note the typo in your relayed stanza. The square bracket must be closed before the colon, thus: relayhost = [127.0.0.1]: 54321. Thanks for the feedback on the postfix. I always used sendmail earlier, somewhat blindly, and now, at your suggestion, postfix was installed and used and found a configuration of absolute delight compared to sendmail!

0
source

All Articles