Msmtp: Difference between revisions
imported>Onny m Minor cleanup |
imported>Onny Refactor page |
||
Line 1: | Line 1: | ||
[https://marlam.de/msmtp/ msmtp] is a basic email sender client. It is easy to configure but lacks some features like queuing when offline. | [https://marlam.de/msmtp/ msmtp] is a basic email sender client. It is easy to configure but lacks some features like queuing when offline. | ||
== | == Installation == | ||
A minimal configuration to relay mails through an external mail server coud look like this | |||
{{warning|1=Do not use a plaintext password in production, this is for demonstration only}} | |||
<syntaxhighlight lang="nix"> | |||
programs.msmtp = { | |||
enable = true; | |||
accounts = { | |||
default = { | |||
host = "example.org"; | |||
from = "hello@example.org"; | |||
user = "hello@example.org"; | |||
password = "mypassword123"; | |||
}; | |||
}; | |||
}; | |||
</syntaxhighlight> | |||
In this case ''msmtp'' will try to deliver mails through the smtp server <code>example.org</code> on port <code>25</code>. <code>user</code> and <code>password</code> are used for normal plaintext authentication. | |||
This configuration will automatically set ''msmtp'' as the default mail delivery client on your system by overwriting the <code>sendmail</code> binary. To test mail delivery issue following command: | |||
<code>user</code> | |||
== Configuration == | |||
Further configuration options for ''msmtp'' can be found [https://marlam.de/msmtp/msmtp.html here]. | |||
=== TLS connections === | |||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
Line 21: | Line 53: | ||
Note that msmtp has no daemon and runs as the invoking user. If using <code>passwordeval</code>, the file must be readable by any user that wishes to send mail. | Note that msmtp has no daemon and runs as the invoking user. If using <code>passwordeval</code>, the file must be readable by any user that wishes to send mail. | ||
== Aliases == | === Aliases === | ||
Example: | Example: | ||
Line 41: | Line 73: | ||
== See also == | == See also == | ||
* [https://search.nixos.org/options?query=programs.msmtp msmtp options list] | * [https://search.nixos.org/options?query=programs.msmtp msmtp options list] | ||
[[Category:Applications]] | [[Category:Applications]] |
Revision as of 14:03, 7 September 2022
msmtp is a basic email sender client. It is easy to configure but lacks some features like queuing when offline.
Installation
A minimal configuration to relay mails through an external mail server coud look like this
programs.msmtp = {
enable = true;
accounts = {
default = {
host = "example.org";
from = "hello@example.org";
user = "hello@example.org";
password = "mypassword123";
};
};
};
In this case msmtp will try to deliver mails through the smtp server example.org
on port 25
. user
and password
are used for normal plaintext authentication.
This configuration will automatically set msmtp as the default mail delivery client on your system by overwriting the sendmail
binary. To test mail delivery issue following command:
user
Configuration
Further configuration options for msmtp can be found here.
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
Example:
programs.msmtp.defaults = {
aliases = "/etc/aliases";
};
environment.etc = {
"aliases" = {
text = ''
root: me@example.com
'';
mode = "0644";
};
};