StackStorm/st2

Use ssmtp instead of sendmail for st2actionrunner

sburlappp opened this issue · 7 comments

Please consider using ssmtp for email sending from core.sendmail:

https://manpages.ubuntu.com/manpages/focal/en/man8/ssmtp.8.html

Recent versions of sendmail don't work well without configuration, which is difficult within a Docker container.

Ubuntu provides a package for ssmtp, which provides an alternative sendmail executable, suitable for typical smarthost setups. It can be configured easily via two small text files, which can be mounted as volumes.

Locally tested and works well.

arm4b commented

Transferred this feature request to the core st2 repository.
The core.sendmail action in question is: https://github.com/StackStorm/st2/blob/master/contrib/core/actions/sendmail.yaml

ssmtp is available in EPEL 7 for Centos, but I do not think it is available for RHEL 8 derivatives - so using it I believe would break Centos 8/Rocky 8/RHEL8.
Is there an alternative that is available both for the Ubuntu but also the RHEL/Rocky/CentOS OSes.

StackStorm is not limited to containers and should not be imposing a specific MTA on its users.

The core.sendmail action provides the sendmail_binary parameter to override using the default sendmail binary, I would expect people can use this feature to target a binary other than sendmail if that's required.

sendmail is the most sane binary to reference because, ssmtp (https://linux.die.net/man/8/ssmtp), postfix (https://linux.die.net/man/1/sendmail.postfix), exim (https://linux.die.net/man/8/exim), courier (https://manpages.org/sendmail) opensmtp (https://www.man7.org/linux/man-pages/man8/sendmail.8.html) and sendmail itself provides binary compatibility that makes it the common denominator for most environments.

arm4b commented

Quite valuable insights!
Based on comments, I'm guessing it's wontfix

/etc/sbin/ssmtp -t

is the binary path needed to read the TO from the input file.

we should consider adding ssmtp to our container builds. sendmail is impossible to setup insiide a container due to it needing to

  1. run the sendmail daemon in the background,
  2. config file needs adjustment ,
  3. the config file needs to be compiled to output a sendmail.cf
  4. the /etc/hosts file needs a valid ip address linked to a valid fqdn. if this is not set then sendmail hangs.

using ssmtp allows the config file to be controlled via configmap in values.yaml.

core.sendmail uses a bash script to send messages but there is the also the option of using the email pack that has send_email. This pack implements mail delivery in pure python and doesn't rely on shell binaries. https://github.com/StackStorm-Exchange/stackstorm-email/blob/master/actions/send_email.yaml