How do I get scripts to run prior to and after sending mail with msmtp?

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?

Roxy

Posted 2018-05-31T14:29:01.490

Reputation: 237

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... – user1686 – 2018-05-31T15:32:14.077

@grawity: Why? sendmail and msmtp can live together on the same system, they are 2 separate binaries. Maybe you think about postfix. – Arkadiusz Drabczyk – 2018-05-31T15:34:40.597

I do not have sendmail installed. This question is about how to use msmtp, not whether I have a traditional MTA installed. – Roxy – 2018-05-31T16:27:05.507

Answers

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.

user2068707

Posted 2018-05-31T14:29:01.490

Reputation: 26