...making Linux just a little more fun!

<-- 2c Tips | TAG Index | 1 | 2 | 3 | 4 | Knowledge Base | News Bytes -->

The Answer Gang

By Jim Dennis, Karl-Heinz Herrmann, Breen, Chris, and... (meet the Gang) ... the Editors of Linux Gazette... and You!



(?) Mail forwarding

From Ben Okopnik

Answered By: Jay R. Ashworth, Breen Mullins, Rick Moen, Jimmy O'Regan, Thomas Adam

Damn, I'm starting to foam at the mouth and twitch uncontrollably. This Mutt + SMTP-via-SSH-tunnel thing's got me going batty...

Mutt doesn't want to know anything about ports or hosts; instead, it invokes Sendmail directly. The SSH tunnel is trivial to set up, but I can't use it - despite spending the entire evening Googling for a possible answer. I really don't want to switch to another email client, either. Do any of you folks have a suggestion?

(!) [Jay] It's often forgotten that ssh can be used to run a command at the other end; have you considered using it to run the local-injection program on the remote server?

(?) Local-injection program - define, please? I've got it all working now (with the exception of a warning message from fetchmail that I'm too busy to chase down ATM), but I'm still curious about other ways to handle it.

(!) [Jay] Pipe your mail message to
ssh remotehost /usr/bin/sendmail
and let sshd remotely run it with the piped stdin as the message source. /usr/bin/sendmail is still almost always a link to something that can deal with that, even these days, no?
Local injection is a phrase I generalized from the wmail and postfix doco...

(?) I think I may have it. :)))

Finally found the one page on the Net that simply explains exactly the process I needed:

http://revjim.net/comments/3734

(!) [Jimmy]
You could try using Msmtp: http://msmtp.sourceforge.net but that probably has issues of its own.

(?) [Ben] It does. I read about a guy who was using esmtp and msmtp, and he got them working with this kind of thing, but I don't really want to drop Exim, either; it's proven itself over time.

(!) [Breen]
I've only just started using Mutt myself. What I think you're going to have to do is get an MSA on your box -- something like http://msmtp.sourceforge.net "msmtp is an SMTP client that can be used as an "SMTP plugin" for Mutt and probably other MUAs (mail user agents). It forwards mails to an SMTP server (for example at a free mail provider) which does the delivery. To use this program, create a configuration file with your mail account(s) and tell your MUA to call msmtp instead of /usr/sbin/sendmail."

(?) Actually, that's one of the things I wanted to avoid doing - much as I like null-mailers. Picture this scenario: I'm at a Net cafe that's got SSH blocked but 25 open (it's happened). Whups! No outgoing mail for me, then, unless I resort to webmail (Nextel does not provide SMTP or POP - connectivity only.)

In essence, I want to retain full SMTP capability but be able to switch between doing that and forwarding 25 (and/or 995, if necessary.) This week's been sorta amusing in that regard: Earthlink blocks 25 but leaves 995 open; Sun's firewall is the opposite. Setting up Exim as I'd mentioned, plus adding another "poll" section to my ~/.fetchmailrc, and running

su -c 'sh ben@linuxgazette.net -L 2525:linuxgazette.net:25 -L 995:linuxgazette.net:995'

takes care of both - and should work fine with my cell setup when I get back home. The only thing I get to pay for is the additional SSH overhead for all my mail transactions, but it's not a big deal. The only thing I don't get is why I have to do the "su" bit; the first forward doesn't require it, but adding 995 - which is obviously not a low port - makes the connection fail.

(!) [Breen] Then you'll want to use a hook in mutt to conditionally set $sendmail to 'msmtp' instead of the default pointing to your sendmail so that the right program gets invoked at the right time. You'll point mstmp to deliver to your end of the tunnel, of course.
(!) [Thomas] So to cut the ramble down, it's YANM (Yet Another Null Mailer) :)
(!) [Rick] One of my favourite places to shop is the Linuxmafia Knowledgebase. See: "Nullmailers" on http://linuxmafia.com/kb/Mail

This page edited and maintained by the Editors of Linux Gazette
HTML script maintained by Heather Stern of Starshine Technical Services, http://www.starshine.org/


Each TAG thread Copyright © its authors, 2004

Published in issue 106 of Linux Gazette September 2004

<-- 2c Tips | TAG Index | 1 | 2 | 3 | 4 | Knowledge Base | News Bytes -->
Tux