Msmtp: Difference between revisions
imported>Cyounkins Initial creation |
msmtp includes the msmtp-queue script to queue offline messages. |
||
(11 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
[https://marlam.de/msmtp/ msmtp] is | [https://marlam.de/msmtp/ msmtp] is an easy to configure basic email sender client with fairly complete sendmail compatibility. | ||
== 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: | |||
<syntaxhighlight lang="console"> | |||
# echo -e "Content-Type: text/plain\r\nSubject: Test\r\n\r\nHello World" | sendmail john.doe@mail.com | |||
</syntaxhighlight> | |||
A mail with the subject ''Test'' will be sent to the recipient ''john.doe@mail.com'' including the body text ''Hello World''. A Mime-Header is added to the mail content for better compatibility. | |||
== 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 12: | Line 42: | ||
auth = true; | auth = true; | ||
tls = true; | tls = true; | ||
# try setting `tls_starttls` to `false` if sendmail hangs | |||
from = "<from address here>"; | from = "<from address here>"; | ||
host = "<hostname here>"; | host = "<hostname here>"; | ||
Line 23: | Line 54: | ||
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: | |||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
programs.msmtp. | programs.msmtp.defaults = { | ||
aliases /etc/aliases | aliases = "/etc/aliases"; | ||
}; | |||
environment.etc = { | environment.etc = { | ||
Line 41: | Line 72: | ||
}; | }; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== See also == | |||
* [https://search.nixos.org/options?query=programs.msmtp msmtp options list] | |||
[[Category:Applications]] |