Msmtp: Difference between revisions
imported>Tompurl mNo edit summary |
msmtp includes the msmtp-queue script to queue offline messages. |
||
(4 intermediate revisions by 2 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 == | == Installation == | ||
Line 24: | Line 24: | ||
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
# sendmail john.doe@mail.com | # echo -e "Content-Type: text/plain\r\nSubject: Test\r\n\r\nHello World" | sendmail john.doe@mail.com | ||
</syntaxhighlight> | </syntaxhighlight> | ||
A mail with the subject ''Test | 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 == | == Configuration == |
Latest revision as of 09:59, 31 October 2024
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
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:
# echo -e "Content-Type: text/plain\r\nSubject: Test\r\n\r\nHello World" | sendmail john.doe@mail.com
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 here.
TLS connections
programs.msmtp = {
enable = true;
accounts = {
default = {
auth = true;
tls = true;
# try setting `tls_starttls` to `false` if sendmail hangs
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";
};
};