Msmtp

From NixOS Wiki
Revision as of 22:06, 19 April 2022 by imported>Cyounkins (Initial creation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

msmtp is a basic email sender. It is easy to configure but lacks some features like queuing when offline.

msmtp options list

Basic configuration with TLS connections

programs.msmtp = {
  enable = true;
  accounts = {
    default = {
      auth = true;
      tls = true;
      from = "<from address here>";
      host = "<hostname here>";
      user = "<username here>";
      passwordeval = "cat /secrets/smtp_password.txt";
    };
  };
};

Note that msmtp has no daemon and runs as the invoking user. If using passwordeval, the file must be readable by any user that wishes to send mail.

Aliases

Adding extraConfig and creating /etc/aliases may be needed for aliases to work:

programs.msmtp.extraConfig = ''
  aliases /etc/aliases
'';

environment.etc = {
  "aliases" = {
    text = ''
      root: me@example.com
    '';
    mode = "0644";
  };
};