mirror of
https://github.com/nix-community/home-manager
synced 2024-11-20 10:09:45 +01:00
neomutt: fix STARTTLS
When smtps is used as a protocol, neomutt expects TLS but will if STARTTLS should be used. When using STARTTLS, smtp has to be used as protocol and `ssl_force_tls` is set. See <https://neomutt.org/guide/optionalfeatures#2-1-%C2%A0starttls>.
This commit is contained in:
parent
0ed5f9786b
commit
408ba13188
4 changed files with 85 additions and 2 deletions
|
@ -118,7 +118,8 @@ let
|
||||||
sendmail = "'${neomutt.sendMailCommand}'";
|
sendmail = "'${neomutt.sendMailCommand}'";
|
||||||
} else
|
} else
|
||||||
let
|
let
|
||||||
smtpProto = if smtp.tls.enable then "smtps" else "smtp";
|
smtpProto =
|
||||||
|
if smtp.tls.enable && !smtp.tls.useStartTls then "smtps" else "smtp";
|
||||||
smtpPort = if smtp.port != null then ":${toString smtp.port}" else "";
|
smtpPort = if smtp.port != null then ":${toString smtp.port}" else "";
|
||||||
smtpBaseUrl =
|
smtpBaseUrl =
|
||||||
"${smtpProto}://${escape userName}@${smtp.host}${smtpPort}";
|
"${smtpProto}://${escape userName}@${smtp.host}${smtpPort}";
|
||||||
|
@ -217,7 +218,9 @@ let
|
||||||
}";
|
}";
|
||||||
in ''
|
in ''
|
||||||
# Generated by Home Manager.
|
# Generated by Home Manager.
|
||||||
set ssl_force_tls = yes
|
set ssl_force_tls = ${
|
||||||
|
lib.hm.booleans.yesNo (smtp.tls.enable || smtp.tls.useStartTls)
|
||||||
|
}
|
||||||
set certificate_file=${toString config.accounts.email.certificatesFile}
|
set certificate_file=${toString config.accounts.email.certificatesFile}
|
||||||
|
|
||||||
# GPG section
|
# GPG section
|
||||||
|
|
|
@ -11,4 +11,5 @@
|
||||||
neomutt-with-named-mailboxes = ./neomutt-with-named-mailboxes.nix;
|
neomutt-with-named-mailboxes = ./neomutt-with-named-mailboxes.nix;
|
||||||
neomutt-with-signature = ./neomutt-with-signature.nix;
|
neomutt-with-signature = ./neomutt-with-signature.nix;
|
||||||
neomutt-with-signature-command = ./neomutt-with-signature-command.nix;
|
neomutt-with-signature-command = ./neomutt-with-signature-command.nix;
|
||||||
|
neomutt-with-starttls = ./neomutt-with-starttls.nix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
# Generated by Home Manager.
|
||||||
|
set ssl_force_tls = yes
|
||||||
|
set certificate_file=/etc/ssl/certs/ca-certificates.crt
|
||||||
|
|
||||||
|
# GPG section
|
||||||
|
set crypt_use_gpgme = yes
|
||||||
|
set crypt_autosign = no
|
||||||
|
set crypt_opportunistic_encrypt = no
|
||||||
|
set pgp_use_gpg_agent = yes
|
||||||
|
set mbox_type = Maildir
|
||||||
|
set sort = "threads"
|
||||||
|
|
||||||
|
# MTA section
|
||||||
|
set smtp_pass="`password-command`"
|
||||||
|
set smtp_url='smtp://home.manager@smtp.example.com'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# MRA section
|
||||||
|
set folder='/home/hm-user/Mail/hm@example.com'
|
||||||
|
set from='hm@example.com'
|
||||||
|
set postponed='+Drafts'
|
||||||
|
set realname='H. M. Test'
|
||||||
|
set record='+Sent'
|
||||||
|
set spoolfile='+Inbox'
|
||||||
|
set trash='+Trash'
|
||||||
|
|
||||||
|
|
||||||
|
# Extra configuration
|
||||||
|
color status cyan default
|
||||||
|
|
||||||
|
|
||||||
|
unset signature
|
||||||
|
# notmuch section
|
||||||
|
set nm_default_uri = "notmuch:///home/hm-user/Mail"
|
||||||
|
virtual-mailboxes "My INBOX" "notmuch://?query=tag%3Ainbox"
|
41
tests/modules/programs/neomutt/neomutt-with-starttls.nix
Normal file
41
tests/modules/programs/neomutt/neomutt-with-starttls.nix
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [ ../../accounts/email-test-accounts.nix ];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
accounts.email.accounts = {
|
||||||
|
"hm@example.com" = {
|
||||||
|
notmuch.enable = true;
|
||||||
|
neomutt = {
|
||||||
|
enable = true;
|
||||||
|
extraConfig = ''
|
||||||
|
color status cyan default
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
imap.port = 143;
|
||||||
|
smtp.tls.useStartTls = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
programs.neomutt = {
|
||||||
|
enable = true;
|
||||||
|
vimKeys = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
test.stubs.neomutt = { };
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/neomutt/neomuttrc
|
||||||
|
assertFileExists home-files/.config/neomutt/hm@example.com
|
||||||
|
assertFileContent home-files/.config/neomutt/neomuttrc ${
|
||||||
|
./neomutt-expected.conf
|
||||||
|
}
|
||||||
|
assertFileContent home-files/.config/neomutt/hm@example.com ${
|
||||||
|
./hm-example.com-starttls-expected
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue