Contributions of novel scenarios for using extsmail are always welcome.
Instead of extsmail calling sendmail
on a remote host, it is possible to setup extsmail chains. This can be useful if you have access to a backup machine which can’t send e-mail directly (e.g. it’s on a dynamic IP address) but which has access (via password-less ssh keys) to another machine which can. The backup machine can then use extsmail to wait until the main machine is up again, and then send the e-mail via it. For example, if you are mostly working offline with only occasional internet access, it is often preferable for a server to accept your e-mail, even if it can not immediately deliver the message itself.
For such a scenario, the externals
file on your laptop may look as follows:
$ hostname -s laptop $ cat .extsmail/externals group { external main { sendmail = "/usr/bin/ssh -q -C -l user main.mymachine.net /usr/sbin/sendmail" } external bk { sendmail = "/usr/bin/ssh -q -C -l user bk.mymachine.net /usr/local/bin/extsmail" } } $
and on bk as follows:
$ hostname bk.mymachine.net $ cat .extsmail/externals group { external main { sendmail = "/usr/bin/ssh -q -C -l user main.mymachine.net /usr/sbin/sendmail" } } $
Particularly in the case where externals are commands to remote servers, it is often the case that one server is particularly preferred, with backup servers only to be used in unusual circumstances. However temporary network failures can often make it appear that a server is down, though a retry a few seconds later might succeed. The timeout
option on externals informs extsmaild that it should retry that external over a given period of time before moving onto the next external in the list. timeout
takes a time argument which is a number followed by d
(days), h
(hours), m
(minutes), or s
(seconds). Note that timeout
only has an effect when extsmaild is run in daemon mode: in batch mode, timeout
is ignored.
For example, the following externals file tells extsmaild to try sending e-mail via main
for 5 minutes before, if still unsuccessful, trying bk
. If main
comes back online at any point and attempts to send e-mail via it succeed, the counter is reset.
$ hostname -s laptop $ cat .extsmail/externals group { external main { timeout = 5m sendmail = "/usr/bin/ssh -q -C -l user main.mymachine.net /usr/sbin/sendmail" } external bk { sendmail = "/usr/bin/ssh -q -C -l user bk.mymachine.net /usr/local/bin/extsmail" } } $