4

I'm going nuts here, trying to get my system configured.

I have a laptop at home and a workstation at work. I use mutt and sendmail. I have a home ISP that is on a lot of blacklists, so that any email I send from my laptop through my ISP is frequently blocked as spam by the receiver. I can SSH to my workstation and use mutt there interactively, but it is slow and tedious. I download my email from the work server to the laptop with fetchmail.

I've tried to get the laptop to send mail through the work mailer using

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

but it seems that sendmail cannot be running when I do this. When I try to fetchmail from workstation to the laptop sendmail must be running on the laptop for the mail to be delivered locally at the laptop. When mail does go through it gets rejected because the hostname is not recognised. I've tried changing the hostname in mutt. This appears not to affect anything.

So I'm confused about how to configure mutt, sendmail and SSH on my laptop, so that I can compose and send emails from my laptop such that they get delivered, yet I also want to get my emails from the server with fetchmail and have it delivered locally.

Any help appreciated.

P̲̳x͓L̳
  • 3,615
  • 3
  • 29
  • 37
Chris Duncombe Rae
  • 603
  • 1
  • 7
  • 9

2 Answers2

7

If you run that ssh tunnel, you can't be running sendmail locally because otherwise it will be listening on port 25, not your tunnel. And fetchmail by default wants a local mail server to deliver to, although you could configure it to deliver to an mbox file directly if you prefer.

What I do instead is I run postfix on my laptop, and have it set up 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 -N -L 2526:localhost:25 ptomblin@myserver so that when postfix goes to deliver, it tunnels out through the tunnel. And local mail clients like mutt and fetchmail see a local mail server running on port 25 like they expect.

Paul Tomblin
  • 179,021
  • 58
  • 319
  • 408
  • Sorry but I am very new with this? am in the same boat as the oruginal poster (over 11 years later) , but wondering how to run the ssh tunnel. Where do I put the run ssh command? Does this go into the postfx main.cf? An added complication is that my ssh connection will need to check if vpn is on because that is how I can connect on ssh to the remote server but I figured that I have to first understand this part. – user3236841 Mar 21 '20 at 01:55
  • You have to run the ssh command manually, or as a however you start up scripts on boot - I used to do it in /etc/rc.local, or as a login item in macOS. – Paul Tomblin Mar 22 '20 at 07:02
  • Thank you. As an alternative, I have found that my e-mails do not go to recipient's junk mail if my vpn is up. I wonder if it is possible to postpone or delay postfix for when/until vpn is up. I put a question here: https://stackoverflow.com/questions/60792180/force-postfix-to-delay-service-until-vpn-is-up but I don't know how to get started on this. It is an odd question. Do you have any suggestions? – user3236841 Mar 22 '20 at 12:56
0

Paul: your answer did the business! I was confused and should have been specifying -L 54321:localhost:25 instead of -L 54321:remotehost:25. Note the typo in your relayhost stanza. The square bracket should be closed before the colon, thus: relayhost=[127.0.0.1]:54321. Thanks for the tip on postfix. I have always used sendmail previously, somewhat blindly, and now on your suggestion have installed and used postfix and find the configuration an absolute delight in comparison to sendmail!

Chris Duncombe Rae
  • 603
  • 1
  • 7
  • 9