Differences between revisions 4 and 5
Revision 4 as of 2019-08-15 21:00:08
Size: 2050
Editor: nodiscc
Comment: add CategoryNetwork CategorySoftware CategoryMail
Revision 5 as of 2019-11-14 21:47:11
Size: 2181
Editor: RicardoCosta
Comment: Insert link to Brazilian translation.
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
~-[[DebianWiki/EditorGuide#translation|Translation(s)]]: [[pt_BR/HowtoSendWithEximThroughSSH|Português Brasileiro]] - English-~

Translation(s): Português Brasileiro - English

How to send mail with Exim through an SSH tunnel

A. Start the ssh tunnel

ssh $HOST -L 2525:$MSERVER:25

(where $HOST is the host you're tunneling through and $MSERVER is the outbound SMTP server you want to use)

B. Configure exim

1. Add a new transport file /etc/exim4/conf.d/transport/40_tunneled_smtp :

  #################################
  # This transport is used for delivering messages over SSH-tunneled SMTP
  # connections to port 2525 on localhost

  ssh_tunneled_smtp:
    debug_print = "T: tunneled remote_smtp for $local_part@$domain"
    driver = smtp
    allow_localhost = true
    port = 2525
    hosts = 127.0.0.1
    hosts_override = true

2. Edit /etc/exim4/conf.d/router/200_exim4-config_primary. In the 'smarthost:' section, change

      transport = remote_smtp_smarthost

to

      transport = ssh_tunneled_smtp

3. /etc/init.d/exim4 reload

Some variations

  • Pick up the transport to use from a file:

   transport = ${lookup{transport}lsearch{/etc/roaming/exim_options}{$value}{remote_smtp_smarthost}}

then, /etc/roaming/exim_options could contain:

   transport: ssh_tunneled_smtp

or nothing at all to use the default

  • Attempt deliveries only on some networks:

1. Add a new file /etc/exim4/conf.d/main/04_roaming :

  # If the file /etc/roaming/not_online exists, don't send the messages but
  # enqueue them only
  queue_only_file = /etc/roaming/not_online

2. Add ifupdown hooks to create and remove the file:

  iface home inet static
    [...]
    up echo '' > /etc/roaming/exim_options
    up rm -f /etc/roaming/not_online

  iface work inet static
    [...]
    up echo 'transport: ssh_tunneled_smtp' > /etc/roaming/exim_options
    up touch /etc/roaming/not_online


Enrico Zini


CategoryNetwork CategorySoftware CategoryMail