2

I want to be able to send email from mutt through an SSH tunnel I can SSH into the SMTP server, but I don't know how to tell mutt how to use the tunnel to send e-mail.

Can someone help me out, please?

womble
  • 95,029
  • 29
  • 173
  • 228
devin
  • 1,226
  • 3
  • 20
  • 27

2 Answers2

2

Using remote SMTP is described here: https://gitlab.com/muttmua/mutt/-/wikis/MuttFaq/Sendmail

So with the tunnel you'd set up your SMTP to localhost, but with the tunnel port. Eg. you create tunnel 8025->25 on remote:

ssh -L8025:smtp.example.com:25 serv.example.com

And in Mutt configuration (.muttrc) you put:

set smtp_url="smtp://username@localhost:8025/"

BTW. Using remote POP/IMAP here: https://gitlab.com/muttmua/mutt/-/wikis/MuttFaq/RemoteFolder

Flux
  • 103
  • 4
vartec
  • 6,137
  • 2
  • 32
  • 49
1

You don't need to have ssh with local port forwarding running on your own. Both mutt and Neomutt have config option tunnel.

tunnel
Type: string
Default: (empty)

Setting this variable will cause mutt to open a pipe to a command instead of a raw socket. You may be able to use this to set up preauthenticated connections to your IMAP/POP3/SMTP server. Example:

set tunnel="ssh -q mailhost.net /usr/local/libexec/imapd"

Note: For this example to work you must be able to log in to the remote machine without having to enter a password.

When set, Mutt uses the tunnel for all remote connections. Please see “account-hook” in the manual for how to use different tunnel commands per connection.

example:

neomutt -F /dev/null \
  -e 'set tunnel="ssh host.example.com' \
  test@example.com \
  < /tmp/msg
Jakub Jindra
  • 113
  • 5