2023-02-26 16:42:49 +01:00
|
|
|
{ config, lib, ... }:
|
|
|
|
with lib;
|
2023-03-07 19:35:34 +01:00
|
|
|
let
|
|
|
|
cfg = config.email;
|
|
|
|
in
|
2023-02-26 16:42:49 +01:00
|
|
|
{
|
|
|
|
options.email = {
|
2023-03-07 19:35:34 +01:00
|
|
|
enable = lib.mkEnableOption "Allow sending system status e-mails via sendmail";
|
2023-02-26 16:42:49 +01:00
|
|
|
fromAddress = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = "noreply@example.com";
|
|
|
|
description = ''
|
|
|
|
E-Mail address automated e-mails are sent from.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
fromIdentity = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "${config.networking.hostName} <${config.email.fromAddress}>";
|
|
|
|
example = "Maintenance (no reply) <noreply@example.com>";
|
|
|
|
description = ''
|
|
|
|
E-Mail identity automated e-mails are sent from.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
adminEmail = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = "admin@example.com";
|
|
|
|
description = ''
|
|
|
|
E-Mail address automated e-mails are sent to.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2023-03-07 19:35:34 +01:00
|
|
|
|
|
|
|
config.programs.msmtp = lib.mkIf cfg.enable {
|
|
|
|
enable = true;
|
|
|
|
setSendmail = true;
|
|
|
|
accounts = {
|
|
|
|
default = {
|
|
|
|
auth = true;
|
|
|
|
host = "gvfr.de";
|
|
|
|
passwordeval = "cat /secrets/email_password.txt";
|
|
|
|
user = cfg.fromAddress;
|
|
|
|
from = cfg.fromAddress;
|
|
|
|
port = 465;
|
|
|
|
tls = true;
|
|
|
|
tls_starttls = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-02-26 16:42:49 +01:00
|
|
|
}
|