0

I would like to use msmtp to send mail on my Linux machine. Before and after sending mail using this tool, I would like to execute some scripts to do some setup and teardown.

I don't see an msmtp configuration option to run scripts before and after sending mail. I don't want to "hack" the system by replacing the binary with a script that will do the work. Do I have another option to do this?

3
  • Eh, in a way, you are already "hacking" the system by replacing /usr/sbin/sendmail (traditionally a full MTA with queueing and so on) with something like msmtp... May 31, 2018 at 15:32
  • @grawity: Why? sendmail and msmtp can live together on the same system, they are 2 separate binaries. Maybe you think about postfix. May 31, 2018 at 15:34
  • I do not have sendmail installed. This question is about how to use msmtp, not whether I have a traditional MTA installed.
    – Roxy
    May 31, 2018 at 16:27

1 Answer 1

0

Unfortunately a hack is the only option you have - Linux is not watching and reacting to each and every binary you call so that it can insert pre- and post-action hooks.

Best approach would be to write a custom function and put it into your .bashrc.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .