1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249
|
\input texinfo @c -*-texinfo-*-
@setfilename msmtp.info
@documentlanguage en
@documentencoding UTF-8
@include version.texi
@settitle msmtp @value{VERSION}
@c Define new indices: for options (op) and commands (cm)
@defcodeindex op
@defcodeindex cm
@finalout
@copying
This manual was last updated @value{UPDATED} for version
@value{VERSION} of msmtp.
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014
Martin Lambers@*
Copyright (C) 2011
Scott Shumate
@quotation
Copying and distribution of this file, with or without modification, are
permitted in any medium without royalty provided the copyright notice and this
notice are preserved. These files are offered as-is, without any warranty.
@end quotation
@end copying
@dircategory Individual utilities
@direntry
* msmtp: (msmtp). An SMTP client.
@end direntry
@titlepage
@title msmtp
@subtitle Version @value{VERSION}, @value{UPDATED}
@author Martin Lambers (@email{marlam@@marlam.de})
@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage
@contents
@ifnottex
@node Top
@top msmtp
@insertcopying
@end ifnottex
@menu
* Introduction:: Basic concepts.
* Configuration files:: Configuration file commands.
* Invocation:: Command line options.
* Transport Layer Security:: How to use TLS/SSL.
* Authentication:: How to use authentication.
* Delivery Status Notifications:: How to use DSN.
* Sendmail mode:: How to send mail.
* Server information mode:: How to obtain information about
an SMTP server.
* Remote Message Queue Starting mode:: How to send RMQS requests.
* Examples:: Usage examples.
@end menu
@node Introduction
@chapter Introduction
msmtp is an SMTP client.
In its default mode of operation, it reads a mail from standard input and sends
it to a predefined SMTP server that takes care of proper delivery. Command line
options and exit codes are compatible to sendmail.
Supported SMTP features include:
@itemize
@item Authentication methods PLAIN, LOGIN, CRAM-MD5 and EXTERNAL
(and GSSAPI, SCRAM-SHA-1, DIGEST-MD5, and NTLM when compiled with GNU SASL
support)
@item TLS encrypted connections with the OpenSSL or GnuTLS libraries
(including server certificate verification and the possibility to send
a client certificate)
@item Support for Internationalized Domain Names (IDN)
@item DSN (Delivery Status Notification) support
@item PIPELINING support for increased transmission speed
@item RMQS (Remote Message Queue Starting) support (ETRN keyword)
@end itemize
The best way to start is probably to have a look at the Examples section.
@xref{Examples}.
In addition to sendmail mode, there are two other modes of operation:
@itemize
@item Server information mode. In this mode, msmtp prints as much information as
it can get about a given SMTP server (supported features, maximum
mail size, @dots{}).
@item Remote Message Queue Starting mode. In this mode, msmtp sends a Remote
Message Queue Starting request for a host, domain, or queue to a given SMTP
server.
@end itemize
Normally, a system wide configuration file and/or a user configuration file
contain information about which SMTP server to use and how to use it, but
almost all settings can also be configured on the command line.
The information about SMTP servers is organized in accounts. Each account
describes one SMTP server: host name, authentication settings, TLS settings,
and so on. Each configuration file can define multiple accounts.
@node Configuration files
@chapter Configuration files
msmtp supports a system wide configuration file and a user configuration file.
Both are optional and need not exist.
If it exists and is readable, a system wide configuration file
@code{SYSCONFDIR/msmtprc} will be loaded, where @code{SYSCONFDIR} depends on
your platform. The default is @code{/usr/local/etc}.
Use @code{--version} to find out which directory your version uses.
If it exists and is readable, a user configuration file will be loaded
(@code{~/.msmtprc} by default). Accounts defined in the user configuration
file override accounts from the system configuration file. The user
configuration file must have no more permissions than user read/write.
Configuration data from either file can be changed by command line options.
A configuration file is a simple text file. Empty lines and comment lines
(whose first non-blank character is '#') are ignored. Every other line must
contain a command and may contain an argument to that command.
The argument may be enclosed in double quotes (").
If the first character of a filename is the tilde (~), this tilde will be
replaced by @code{HOME}. If a command accepts the argument @samp{on}, it also
accepts an empty argument and treats that as if it was @samp{on}.
Commands form groups. Each group starts with the @samp{account} command and
defines the settings for one SMTP server.
@xref{Examples}.
@section General commands
@table @samp
@anchor{defaults}
@item defaults
@cmindex defaults
Set defaults. The following configuration commands will set default values for
all following account definitions in the current configuration file.
@anchor{account}
@item account @var{name} [: @var{account}[,@dots{}]]
@cmindex account
Start a new account definition with the given name. The current default values
are filled in (see @ref{defaults}).@*
If a colon and a list of previously defined accounts is given after the account
name, the new account, with the filled in default values, will inherit all
settings from the accounts in the list.
@anchor{host}
@item host @var{hostname}
@cmindex host
The SMTP server to send the mail to.
The argument may be a host name or a network address.
Every account definition must contain this command.
@anchor{port}
@item port @var{number}
@cmindex port
The port that the SMTP server listens on.
The default port will be acquired from your operating system's service database:
for SMTP, the service is "smtp" (default port 25), unless TLS
without STARTTLS is used, in which case it is "smtps" (465). For LMTP, it is
"lmtp".
@anchor{timeout}
@item timeout (off|@var{seconds})
@cmindex timeout
Set or unset a network timeout, in seconds. The argument @samp{off} means that
no timeout will be set, which means that the operating system default will be
used. For compatibility with older versions, @samp{connect_timeout} is
accepted as an alias for this command.
@anchor{protocol}
@item protocol (smtp|lmtp)
@cmindex protocol
Set the protocol to use. Currently only SMTP and LMTP are supported. SMTP is
the default. See @ref{port} for default ports.
@anchor{domain}
@item domain @var{argument}
@cmindex domain
This command sets the argument of the SMTP EHLO (or LMTP LHLO) command. The
default is @samp{localhost}, which is stupid but usually works. Try to change
the default if mails get rejected due to anti-SPAM measures. Possible choices
are the domain part of your mail address (@code{provider.example} for
@code{joe@@provider.example}) or the fully qualified domain name of your host
(if available).
@end table
@section Authentication commands
@xref{Authentication}.
@table @samp
@anchor{auth}
@item auth [(on|off|@var{method})]
@cmindex auth
This command enables or disables SMTP authentication and optionally chooses an
authentication method to use. It should not be necessary to choose a method;
with the argument @samp{on}, msmtp will choose the best one available.
Accepted methods are @samp{plain}, @samp{scram-sha-1}, @samp{cram-md5},
@samp{gssapi}, @samp{external}, @samp{digest-md5}, @samp{login}, and
@samp{ntlm}.
@xref{Authentication}.@*
@anchor{user}
@item user [@var{username}]
@cmindex user
Set your user name for SMTP authentication. An empty argument unsets the user
name. Authentication must be activated with the @samp{auth} command.
@anchor{password}
@item password [@var{secret}]
@cmindex password
Set your password for SMTP authentication. An empty argument unsets the
password. Authentication must be activated with the @samp{auth} command.
If no password is set but one is needed during authentication, msmtp will try to
find it. First, if @samp{passwordeval} is set, it will evaluate that command. If
@samp{passwordeval} is not set, msmtp will try to find the password in
@code{~/.netrc}. If that fails, it will try to find it in
@code{SYSCONFDIR/netrc} (use @code{--version} to find out what @code{SYSCONFDIR}
is on your platform). If that fails, it will try to get it from a system
specific keyring (if available). If that fails but a controlling terminal is
available, msmtp will prompt you for it.
@xref{Authentication}.
@anchor{passwordeval}
@item passwordeval [@var{eval}]
@cmindex passwordeval
Set your password for SMTP authentication to the output (stdout) of the
execution of @var{eval}.
@anchor{ntlmdomain}
@item ntlmdomain [@var{ntlmdomain}]
@cmindex ntlmdomain
Set a domain for the @samp{ntlm} authentication method. The default is to use
no domain (equivalent to an empty argument), but some servers seem to require
one, even if it is an arbitrary string.
@end table
@section TLS commands
@xref{Transport Layer Security}.
@table @samp
@anchor{tls}
@item tls [(on|off)]
@cmindex tls
This command enables or disables TLS/SSL encrypted connections to the SMTP
server. Not every server supports TLS, and a few that support it require the
@samp{tls_starttls off} command.@*
To use TLS/SSL, it is required to either use the @samp{tls_trust_file} command
(highly recommended) or to disable @samp{tls_certcheck}.
@xref{Transport Layer Security}.
@anchor{tls_trust_file}
@item tls_trust_file [@var{file}]
@cmindex tls_trust_file
This command activates strict server certificate verification.
The given file must contain one or more certificates of trusted Certification
Authorities (CAs) in PEM format.@*
On Debian based systems, you can install the @samp{ca-certificates} package and
use the file @file{/etc/ssl/certs/ca-certificates.crt}.@*
An empty argument disables this feature.
@anchor{tls_crl_file}
@item tls_crl_file [@var{file}]
@cmindex tls_crl_file
This command sets or unsets a certificate revocation list (CRL) file for TLS,
to be used during strict server certificate verification as enabled by the
@ref{tls_trust_file} command. This allows the verification procedure to detect
revoked certificates.
@xref{Transport Layer Security}.
@anchor{tls_fingerprint}
@item tls_fingerprint [@var{fingerprint}]
@cmindex tls_fingerprint
This command sets or unsets the fingerprint of a particular TLS certificate.
This certificate will then be trusted, regardless of its contents. This can be
used to trust broken certificates (e.g. with a non-matching hostname) or in
situations where @samp{tls_trust_file} cannot be used for some reason.
You can give either an SHA1 (recommended) or an MD5 fingerprint in the format
@code{01:23:45:67:@dots{}}.
You can use @samp{--serverinfo --tls --tls-certcheck=off} to get the peer
certificate's fingerprints.
@xref{Transport Layer Security}.
@anchor{tls_key_file}
@item tls_key_file [@var{file}]
@cmindex tls_key_file
This command (together with the @samp{tls_cert_file}) command enables msmtp to
send a client certificate to the SMTP server if requested.
The file must contain the private key of a certificate in PEM format.
An empty argument disables this feature.
@xref{Transport Layer Security}.
@anchor{tls_cert_file}
@item tls_cert_file [@var{file}]
@cmindex tls_cert_file
This command (together with the @samp{tls_key_file} command) enables msmtp to
send a client certificate to the SMTP server if requested.
The file must contain a certificate in PEM format.
An empty argument disables this feature.
@xref{Transport Layer Security}.
@anchor{tls_certcheck}
@item tls_certcheck [(on|off)]
@cmindex tls_certcheck
This command enables or disables checks for the server certificate.@*
WARNING: When the checks are disabled, TLS/SSL sessions will be vulnerable to
man-in-the-middle attacks! @xref{Transport Layer Security}.@*
For compatibility with older versions, @samp{tls_nocertcheck} is accepted as an
alias for @samp{tls_certcheck off}.
@anchor{tls_starttls}
@item tls_starttls [(on|off)]
@cmindex tls_starttls
This command enables or disables the use of the STARTTLS SMTP command to start
TLS encryption. It is enabled by default.
@xref{Transport Layer Security}.
For compatibility with older versions, @samp{tls_nostarttls} is accepted as an
alias for @samp{tls_starttls off}.
@anchor{tls_force_sslv3}
@item tls_force_sslv3 [(on|off)]
@cmindex tls_force_sslv3
Force TLS/SSL version SSLv3. This might be needed to use SSL with some old and
broken servers. Do not use this unless you have to.
@xref{Transport Layer Security}.
@anchor{tls_min_dh_prime_bits}
@item tls_min_dh_prime_bits [@var{bits}]
@cmindex tls_min_dh_prime_bits
Set or unset the minimum number of Diffie-Hellman (DH) prime bits that msmtp
will accept for TLS sessions. The default is set by the TLS library and can be
selected by using an empty argument to this command. Only lower the default
(for example to 512 bits) if there is no other way to make TLS work with the
remote server.
@xref{Transport Layer Security}.
@anchor{tls_priorities}
@item tls_priorities [@var{priorities}]
@cmindex tls_priorities
Set the priorities for TLS sessions. The default is set by the TLS library and
can be selected by using an empty argument to this command. Currently this
command only works with sufficiently recent GnuTLS releases. See the GnuTLS
documentation of the @samp{gnutls_priority_init} function for a description of
the @var{priorities} string.
@xref{Transport Layer Security}.
@end table
@section Commands specific to sendmail mode
@xref{Sendmail mode}.
@table @samp
@anchor{auto_from}
@item auto_from [(on|off)]
@cmindex auto_from
Enable or disable automatic envelope-from addresses. The default is
@samp{off}.@*
When enabled, an envelope-from address of the form user@@domain will be
generated. The local part will be set to @code{USER} or, if that fails, to
@code{LOGNAME} or, if that fails, to the login name of the current user. The
domain part can be set with the @samp{maildomain} command (see
@ref{maildomain}). If the maildomain is empty, the envelope-from address will
only consist of the user name and not have a domain part.@*
When disabled, the envelope-from address must be set explicitly with the
@samp{from} command (see @ref{from}).@*
@xref{Envelope-from address}.
@anchor{from}
@item from [@var{address}]
@cmindex from
Set the envelope-from address. This address will only be used when
@samp{auto_from} is disabled.
@xref{Envelope-from address}.
@anchor{maildomain}
@item maildomain [@var{domain}]
@cmindex maildomain
Set a domain part for the generation of an envelope-from address. This is only
used when @samp{auto_from} is enabled. The domain may be empty.
@xref{Envelope-from address}.
@anchor{dsn_notify}
@item dsn_notify (off|@var{condition})
@cmindex dsn_notify
This command sets the condition(s) under which the mail system should send DSN
(Delivery Status Notification) messages. The argument off disables
explicit DSN requests, which means the mail system decides when to send DSN
messages. This is the default.
The @var{condition} must be @samp{never}, to never request notification, or a
comma separated list (no spaces!) of one or more of the following:
@samp{failure}, to request notification on transmission failure, @samp{delay},
to be notified of message delays, @samp{success}, to be notified of successful
transmission.
The SMTP server must support the DSN extension.
@xref{Delivery Status Notifications}.
@anchor{dsn_return}
@item dsn_return (off|@var{amount})
@cmindex dsn_return
This command controls how much of a mail should be returned in DSN (Delivery
Status Notification) messages. The argument off disables explicit DSN
requests, which means the mail system decides how much of a mail it returns in
DSN messages. This is the default.
The @var{amount} must be @samp{headers}, to just return the message headers, or
@samp{full}, to return the full mail.
The SMTP server must support the DSN extension.
@xref{Delivery Status Notifications}.
@anchor{keepbcc}
@item keepbcc [(on|off)]
@cmindex keepbcc
This command controls whether to remove or keep the Bcc header when sending a
mail. The default is to remove it. @xref{Bcc header}.
@anchor{logfile}
@item logfile [@var{file}]
@cmindex logfile
This command enables or disables logging to the specified file. An empty
argument disables this feature. The file name @samp{-} directs the log
information to standard output.
@xref{Logging}.
@anchor{syslog}
@item syslog [(on|off|@var{facility})]
@cmindex syslog
This command enables or disables syslog logging. The facility can be one of
@samp{LOG_USER}, @samp{LOG_MAIL}, @samp{LOG_LOCAL0}, @dots{}, @samp{LOG_LOCAL7}.
The default facility is @samp{LOG_USER}. Syslog logging is disabled by default.
@xref{Logging}.
@anchor{aliases}
@item aliases [@var{file}]
@cmindex aliases
Replace local recipients with addresses in the aliases file. The aliases file
is a plain text file containing mappings between a local address and a list of
domain addresses. A local address is defined as one without an '@@' character
and a domain address is one with an '@@' character. The mappings are of the
form:
@example
local: someone@@example.com, person@@domain.example
@end example
Multiple domain addresses are separated with commas. Comments start with '#'
and continue to the end of the line.@*
The local address @samp{default} has special significance and is matched if the
local address is not found in the aliases file. If no @samp{default} alias is
found, then the local address is left as is.@*
An empty argument to the aliases command disables the replacement of local
addresses. This is the default.
@end table
@node Invocation
@chapter Invocation
@section Synopsis
@itemize
@item Sendmail mode (default):@*
@code{msmtp [@var{option}@dots{}] [--] @var{recipient}@dots{}}@*
@code{msmtp [@var{option}@dots{}] -t [--] [@var{recipient}@dots{}]}
@item Server information mode:@*
@code{msmtp [@var{option}@dots{}] --serverinfo}
@item Remote Message Queue Starting mode:@*
@code{msmtp [@var{option}@dots{}]
--rmqs=(@var{host}|@var{@@domain}|@var{#queue})}
@end itemize
@section Options
Options override configuration file settings. They are compatible with sendmail
where appropriate.
@subsection General options
@table @samp
@item --version
@opindex --version
Print version information. This includes information about the library used for
TLS/SSL support (if any), the library used for authentication, the
authentication mechanisms supported by this library, and the default locations
of the system and user configuration files.
@item --help
@opindex --help
Print help.
@item -P
@itemx --pretend
@opindex -P
@opindex --pretend
Print the configuration settings that would be used, but do not take further
action. An asterisk ('*') will be printed instead of the password.
@item -v
@item -d
@itemx --debug
@opindex -v
@opindex -d
@opindex --debug
Print lots of debugging information, including the whole conversation with the
SMTP server. Be careful with this option: the (potentially dangerous) output
will not be sanitized, and your password may get printed in an easily decodable
format!
@end table
@subsection Changing the mode of operation
@table @samp
@anchor{--serverinfo}
@item -S
@itemx --serverinfo
@opindex -S
@opindex --serverinfo
Print information about the SMTP server and exit. This includes information
about supported features (mail size limit, authentication, TLS, DSN, @dots{})
and about the TLS certificate (if TLS is active).
@xref{Server information mode}.
@anchor{--rmqs}
@item --rmqs=(@var{host}|@var{@@domain}|@var{#queue})
@opindex --rmqs
Send a Remote Message Queue Starting request for the given host, domain, or
queue to the SMTP server and exit.
@xref{Remote Message Queue Starting mode}.
@end table
@subsection Configuration options
Most options in this category correspond to a configuration file command.
Please refer to @ref{Configuration files} for detailed information.
@table @samp
@item -C @var{filename}
@itemx --file=@var{filename}
@opindex -C
@opindex --file
Use the given file instead of @code{~/.msmtprc} as the user configuration
file.
@item -a @var{account}
@itemx --account=@var{account}
@opindex -a
@opindex --account
Use the given account instead of the account named @samp{default}. This option
cannot be used together with the @samp{--host} option.
@xref{Choosing an account}.
@item --host=@var{hostname}
@opindex --host
Use this SMTP server with settings from the command line; do not use any
configuration file data. This option cannot be used together with the
@samp{--account} option. It disables loading of configuration files.
@xref{Choosing an account}.
@item --port=@var{number}
@opindex --port
Set the port number to connect to. @xref{port}.
@item --timeout=(off|@var{seconds})
@opindex --timeout
Set a network timeout. @xref{timeout}. For compatibility with older versions,
@samp{--connect-timeout} is accepted as an alias for this option.
@item --protocol=(smtp|lmtp)
@opindex --protocol
Set the protocol. @xref{protocol}.
@item --domain=[@var{argument}]
@opindex --domain
Set the argument of the SMTP EHLO (or LMTP LHLO) command. @xref{domain}.
@anchor{--auth}
@item --auth[=(on|off|@var{method})]
@opindex --auth
Enable or disable authentication and optionally choose the method. @xref{auth}.
@anchor{--user}
@item --user=[@var{username}]
@opindex --user
Set or unset the user name for authentication. @xref{user}.
@anchor{--passwordeval}
@item --passwordeval=[@var{eval}]
@opindex --passwordeval
Evaluate password for authentication. @xref{passwordeval}.
@item --tls[=(on|off)]
@opindex --tls
Enable or disable TLS/SSL. @xref{tls}.
@anchor{--tls-starttls}
@item --tls-starttls[=(on|off)]
@opindex --tls-starttls
Enable or disable STARTTLS for TLS encryption. @xref{tls_starttls}.
@anchor{--tls-trust-file}
@item --tls-trust-file=[@var{file}]
@opindex --tls-trust-file
Set or unset a trust file for TLS encryption. @xref{tls_trust_file}.
@anchor{--tls-crl-file}
@item --tls-crl-file=[@var{file}]
@opindex --tls-crl-file
Set or unset a certificate revocation list (CRL) file for TLS.
@xref{tls_crl_file}.
@anchor{--tls-fingerprint}
@item --tls-fingerprint=[@var{fingerprint}]
@opindex --tls-fingerprint
Set ot unset the fingerprint of a trusted TLS certificate.
@xref{tls_fingerprint}.
@anchor{--tls-key-file}
@item --tls-key-file=[@var{file}]
@opindex --tls-key-file
Set or unset a key file for TLS encryption. @xref{tls_key_file}.
@anchor{--tls-cert-file}
@item --tls-cert-file=[@var{file}]
@opindex --tls-cert-file
Set or unset a cert file for TLS encryption. @xref{tls_cert_file}.
@anchor{--tls-certcheck}
@item --tls-certcheck[=(on|off)]
@opindex --tls-certcheck
Enable or disable server certificate checks for TLS encryption.
@xref{tls_certcheck}.
@anchor{--tls-force-sslv3}
@item --tls-force-sslv3[=(on|off)]
@opindex --tls-force-sslv3
Force TLS/SSL version SSLv3. @xref{tls_force_sslv3}.
@anchor{--tls-min-dh-prime-bits}
@item --tls-min-dh-prime-bits=[@var{bits}]
@opindex --tls-min-dh-prime-bits
Set or unset minimum bit size of the Diffie-Hellman (DH) prime.
@xref{tls_min_dh_prime_bits}.
@anchor{--tls-priorities}
@item --tls-priorities=[@var{priorities}]
@opindex --tls-priorities
Set or unset TLS priorities. @xref{tls_priorities}.
@end table
@subsection Options specific to sendmail mode
@table @samp
@anchor{--auto-from}
@item --auto-from[=(on|off)]
@opindex --auto-from
Enable or disable automatic envelope-from addresses. The default is off.
@xref{auto_from}.
@anchor{--from}
@item -f @var{address}
@itemx --from=@var{address}
@opindex -f
@opindex --from
Set the envelope-from address. It is only used when @samp{auto_from} is off.
@xref{from}.@*
If no account was chosen yet (with @samp{--account} or @samp{--host}), this
option will choose the first account that has the given envelope-from address
(set with the @samp{from} command). If no such account is found, "default" is
used. @xref{Choosing an account}.
@anchor{--maildomain}
@item --maildomain=[@var{domain}]
@opindex --maildomain
Set the domain part for generated envelope-from addresses. It is only used when
@samp{auto_from} is on. @xref{maildomain}.
@anchor{--dsn-notify}
@item -N (off|@var{condition})
@itemx --dsn-notify=(off|@var{condition})
@opindex -N
@opindex --dsn-notify
Set or unset DSN notification conditions. @xref{dsn_notify}.
@anchor{--dsn-return}
@item -R (off|@var{amount})
@itemx --dsn-return=(off|@var{amount})
@opindex -R
@opindex --dsn-return
Set or unset the DSN notification amount. @xref{dsn_return}.
Note that @samp{hdrs} is accepted as an alias for @samp{headers} to be
compatible with sendmail.
@anchor{--keepbcc}
@item --keepbcc[=(on|off)]
@opindex --keepbcc
Enable or disable the preservation of the Bcc header. @xref{keepbcc}.
@anchor{--logfile}
@item -X [@var{file}]
@itemx --logfile=[@var{file}]
@opindex -X
@opindex --logfile
Set or unset the log file. @xref{logfile}.
@anchor{--syslog}
@item --syslog[=(on|off|@var{facility})]
@opindex --syslog
Enable or disable syslog logging. @xref{syslog}.
@item -t
@itemx --read-recipients
@opindex -t
@opindex --read-recipients
Send the mail to the recipients given in the To, Cc, and Bcc headers of the
mail in addition to the recipients given on the command line.@*
If any Resent- headers are present, then the addresses from any Resent-To,
Resent-Cc, and Resent-Bcc headers in the first block of Resent- headers are
used instead.
@item --read-envelope-from
@opindex --read-envelope-from
Read the envelope from address from the From header of the mail.
Currently this header must be on a single line for this option to work
correctly.
@item --aliases=[@var{file}]
@opindex --aliases
Set or unset an aliases file. @xref{aliases}.
@item --
This marks the end of options. All following arguments will be treated as
recipient addresses, even if they start with a '-'.
@end table
The following options are accepted but ignored for sendmail compatibility:
@samp{-B@var{type}}, @samp{-bm}, @samp{-F@var{name}}, @samp{-G}, @samp{-hN},
@samp{-i}, @samp{-L @var{tag}}, @samp{-m}, @samp{-n},
@samp{-O option=@var{value}}, @samp{-ox @var{value}}
@anchor{Choosing an account}
@section Choosing an account
There are three ways to choose the account to use.
It depends on the circumstances which method is the best.
@enumerate
@item @samp{--account=@var{account}}@*
Use the given account. Command line settings override configuration file
settings.
@item @samp{--host=@var{hostname}}@*
Use only the settings from the command line; do not use any configuration file
data.
@item @samp{--from=@var{address}} or @samp{--read-envelope-from}@*
Choose the first account from the system or user configuration file that has
a matching envelope-from address as specified by a @samp{from} command. This
works only when neither @samp{--account} nor @samp{--host} is used.
@end enumerate
If none of the above options is used (or if no account has a matching
@samp{from} command), then the account "default" is used.
@section Exit code
The standard exit codes from @code{sysexits.h} are used.
@anchor{Files}
@section Files
@table @samp
@item @code{SYSCONFDIR/msmtprc}
The system configuration file. Use the @samp{--version} option to find out what
@code{SYSCONFDIR} is on your platform.
@item @code{~/.msmtprc}
The default user configuration file.
@item @code{~/.netrc} and @code{SYSCONFDIR/netrc}
The @code{netrc} file contains login information. If a password is not found
in the configuration file, msmtp will search it in @code{~/.netrc} and
@code{SYSCONFDIR} before prompting the user for it. The syntax of @code{netrc}
files is described in the @code{netrc(5)} or @code{ftp(1)} manual page.
@end table
@anchor{Environment}
@section Environment
@table @samp
@item @code{USER}, @code{LOGNAME}
These variables override the user's login name when constructing an
envelope-from address. @code{LOGNAME} is only used if @code{USER} is unset.
@item @code{TMPDIR}
Directory to create temporary files in. If this is unset, a system specific
default directory is used.@*
A temporary file is only created when the @samp{-t}/@samp{--read-recipients}
or @samp{--read-envelope-from} option is used. The file is then used to buffer
the headers of the mail (but not the body, so the file won't get very large).
@item @code{EMAIL}, @code{SMTPSERVER}
These environment variables are used only if neither @samp{--host} nor
@samp{--account} is used and there is no default account defined in the
configuration files. In this case, the host name is taken from
@code{SMTPSERVER}, and the envelope from address is taken from @code{EMAIL},
unless overridden by @samp{--from} or @samp{--read-envelope-from}. Currently
@code{SMTPSERVER} must contain a plain host name (no URL), and @code{EMAIL}
must contain a plain address (no names or additional information).
@end table
@node Transport Layer Security
@chapter Transport Layer Security
Transport Layer Security (TLS) is a new name for Secure Socket Layer (SSL).
The TLS 1.0 protocol is an updated version of the SSL 3.0 protocol. TLS and
SSL mean the same thing.
Quoting from RFC2246, the TLS 1.0 protocol specification:@*
"The TLS protocol provides communications privacy over the Internet.
The protocol allows client/server applications to communicate in a way that
is designed to prevent eavesdropping, tampering, or message forgery."
SMTP servers can use TLS in one of two modes:
@itemize
@item Immediately. This is SMTP tunneled through TLS, aka SSMTP. The default
port for this mode is 465 (smtps).
@item Via the STARTTLS SMTP command. The SMTP session begins normally. The
client sends the STARTTLS command when it wishes to begin TLS encryption. The
default port for this mode is the default SMTP port: 25 (smtp).
@end itemize
msmtp can switch between these modes with the @samp{tls_starttls} command (see
@ref{tls_starttls}) command or the @samp{--tls-starttls} option (see
@ref{--tls-starttls}).
When TLS is started, the server sends a certificate to identify itself. This
certificate contains information about the certificate owner, the certificate
issuer, and the activation and expiration times of the certificate. This
information can be displayed in server information mode.
@xref{Server information mode}.
To use TLS, it is required to either enable full server certificate verification
using the @samp{tls_trust_file} command or @samp{--tls-trust-file} option, or to
trust one particular peer certificate using the @samp{tls_fingerprint} command
or @samp{--tls-fingerprint} option, or to disable all certificate checks using
@samp{tls_certcheck off} or @samp{--tls-certcheck=off}.
WARNING: When certificate checks are disabled, TLS/SSL sessions are vulnerable
to man-in-the-middle attacks!
See @ref{tls_trust_file}, @ref{--tls-trust-file}, @ref{tls_fingerprint},
@ref{--tls-fingerprint}, @ref{tls_certcheck}, @ref{--tls-certcheck}.
If your system has a file that collects all system-wide trusted CA
certificates, it is easiest to just use this in the @samp{defaults} section of
your configuration file. On Debian-based systems, for example, the adequate
command would be @samp{tls_trust_file /etc/ssl/certs/ca-certificates.crt}.
But you can also find out manually which CA certificate you need to
trust. First, issue the following command:
@example
$ msmtp --serverinfo --host=smtp.example.com --tls=on --tls-certcheck=off
@end example
The option @samp{--tls-certcheck=off} allows msmtp to accept any certificate,
so that it can print some information about it. The output of this command
tells you the common name of the server certificate issuer. You have to trust
this issuer to use full TLS security. Usually you can find the CA certificate
on the issuer's homepage. With this CA certificate, the following should
succeed:
@example
$ msmtp --serverinfo --host=smtp.example.com --tls=on \
--tls-trust-file=ca_cert.txt
@end example
If the server requests it, the client can send a certificate, too. This allows
the server to verify the identity of the client. See the EXTERNAL mechanism in
@ref{Authentication}. The @samp{tls_key_file}/@samp{tls_cert_file} commands or
the @samp{--tls-key-file}/@samp{--tls-cert-file} options can be used to set a
client certificate. See @ref{tls_key_file}/@ref{--tls-key-file},
@ref{tls_cert_file}/@ref{--tls-cert-file}.
Note that GnuTLS will only send a client certificate if it matches one of the
CAs advertised by the server. If you set a client certificate but it is not sent
to the server, it probably was not issued by any CA that the server trusts.
If you need to fine tune TLS parameters or have problems connecting to your
server, have a look at the @ref{tls_force_sslv3}, @ref{tls_min_dh_prime_bits},
and @ref{tls_priorities} commands.
@node Authentication
@chapter Authentication
Many SMTP servers require a client to authenticate itself before it is allowed
to send mail.
Multiple authentication methods exist. Most SMTP servers support only some of
them. Some methods send authentication data in plain text (or nearly plain
text) to the server. These methods should only be used when TLS is active to
prevent others from stealing the password. @xref{Transport Layer Security}.
By default, msmtp chooses a method automatically, and it will never choose one
that puts the authentication data at risk. See below for details.
msmtp supports the following authentication methods:
@itemize
@item @samp{PLAIN}@*
This authentication method needs a user name and a password.
Both are send in BASE64 encoding, which can be easily decoded to plain text.
@item @samp{SCRAM-SHA-1}@*
This authentication method needs a user name and a password.
The authentication data is not sent in plain text, which means this method can
safely be used without TLS.
@item @samp{CRAM-MD5}@*
This authentication method needs a user name and a password.
The authentication data is not sent in plain text, which means this method can
safely be used without TLS.
@item @samp{GSSAPI}@*
This authentication method needs a user name. The Kerberos framework takes care
of secure authentication, therefore this method can safely be used without TLS.
@item @samp{EXTERNAL}@*
This is a special authentication method: The actual authentication happens
outside of the SMTP protocol, typically by sending a TLS client certificate
(see @ref{Transport Layer Security}).@*
The EXTERNAL method merely confirms that this authentication succeeded for the
given user (or, if no user name is given, confirms that authentication
succeeded). Thus it may not be necessary for authentication to use this method,
and if the server does not support the EXTERNAL method, this does not mean that
it does not support authentication with TLS client certificates.@*
This authentication method is not chosen automatically; you have to request it
manually.@*
Note: Sendmail 8.12.11 advertises the EXTERNAL mechanism only after a TLS
client certificate has been send. It seems to ignore the optional user name.
Does anyone know more about this?
@item @samp{DIGEST-MD5}@*
This is an obsolete authentication method needs a user name and a password.
The authentication data is not sent in plain text, but the encryption based on
MD5 is not considered secure anymore.
@item @samp{LOGIN}@*
This is a non-standard authentication method similar to (but worse than) PLAIN.
It needs a user name and a password, both of which are send in BASE64 encoding,
which can be easily decoded to plain text.
@item @samp{NTLM}@*
This is an obscure non-standard authentication method. It needs a user name and
a password and in some cases a special domain parameter (see @ref{ntlmdomain}).
The authentication data is not send in plain text, but since NTLM is not an open
standard, it should be considered broken and insecure.
@end itemize
It depends on the underlying authentication library and its version whether a
particular method is supported or not. Use the @option{--version} to find out
which methods are supported by your version of msmtp.
Authentication data can be set with the @samp{user} and @samp{password} commands
or with the @samp{--user} option. See @ref{user}, @ref{password}, @ref{--user}.
If no password is set but one is needed during authentication, msmtp will try to
find it. First, if @samp{passwordeval} is set, it will evaluate that command. If
@samp{passwordeval} is not set, msmtp will try to find the password in
@code{~/.netrc}. If that fails, it will try to find it in
@code{SYSCONFDIR/netrc} (use @code{--version} to find out what @code{SYSCONFDIR}
is on your platform). If that fails, it will try to get it from a system
specific keyring (if available). If that fails but a controlling terminal is
available, msmtp will prompt you for it.
Currently supported keyrings are the Gnome Keyring and the Mac OS X Keychain.
The script @code{msmtp-gnome-tool.py} can be used to manage Gnome Keyring
passwords for msmtp. To manage Mac OS X Keychain passwords, use the Keychain
Access GUI application. The @samp{account name} is same as the msmtp @samp{user}
argument. The @samp{keychain item name} is @code{smtp://<hostname>} where
@code{<hostname>} matches the msmtp @samp{host} argument.
The authentication method can be chosen with the @samp{auth} command or
@samp{--auth} option, but it is usually sufficient to just use the @samp{on}
argument to let msmtp choose the method itself. See @ref{auth}, @ref{--auth}.
If msmtp chooses the method itself, it will never choose an insecure method.
If TLS is active, all methods are considered secure in this context, because the
connection to the server is protected by TLS. If TLS is not active, only the
SCRAM-SHA-1, CRAM-MD5, and GSSAPI methods are considered secure in this
context, because all the others methods put the authentication data at risk.
If you really want to risk your authentication data, you have to force msmtp to
do that by manually setting the authentication method while TLS is off.
@node Delivery Status Notifications
@chapter Delivery Status Notifications
In situations such as delivery failure or very long delivery delay, the mail
system often generates a message for the sender of the mail in question,
informing him about the difficulties.
Delivery Status Notification (DSN) requests, defined in RFC 3461, try to give
the sender of the mail control about how and when these DSN messages are sent.
The SMTP server must support the DSN extension. @xref{Server information mode}.
A first parameter controls when such messages should be generated:
never, on delivery failure, on delivery delay, and/or on success.
This can be set with @samp{dsn_notify}/@samp{--dsn-notify}, see
@ref{dsn_notify}/@ref{--dsn-notify}.
A second parameter controls how much of the original mail should be contained
in a DSN message: only the headers, or the full mail. This can be set with
@samp{dsn_return}/@samp{--dsn-return}, see @ref{dsn_return}/@ref{--dsn-return}.
Note that this parameter only applies to DSNs that indicate delivery failure
for at least one recipient. If a DSN contains no indications of delivery
failure, only the headers of the message are returned.
@node Sendmail mode
@chapter Sendmail mode
@menu
* Envelope-from address:: Information about envelope-from addresses
* Logging:: Different logging methods
* Bcc header:: Bcc header handling
@end menu
@node Envelope-from address
@section Envelope-from address
The SMTP server expects a sender mail address for each mail. This is the
envelope-from address. It is independent of the From header (because it is
part of the mail @emph{envelope}, not of the mail itself), but in most cases
both addresses are the same.
Envelope-from addresses can be generated automatically (when @samp{auto_from}
is enabled with the @samp{auto_from} command or @samp{--auto-from} option) or
set explicitly with the @samp{from} command and @samp{--from} option.
See @ref{auto_from}, @ref{from}.
When @samp{auto_from} is enabled, an envelope-from address of the form
user@@domain will be generated. The local part will be set to @code{USER} or,
if that fails, to @code{LOGNAME} or, if that fails, to the login name of the
current user. The domain part can be set with the @samp{maildomain} command
and @samp{--maildomain} option (see @ref{maildomain}). If the maildomain is
empty, the envelope-from address will only consist of the user name and not
have a domain part.
@node Logging
@section Logging
Logging is enabled on a per account basis. If it is enabled, msmtp will generate
one log line for each mail it tries to send via the account in question.
The line will include the following information:
@itemize
@item Host name of the SMTP server: @code{host=hostname}
@item Whether TLS was used: @code{tls=(on|off)}
@item Whether authentication was used: @code{auth=(on|off)}
@item The user name used for authentication (only if authentication is used):
@code{user=name}
@item The envelope-from address: @code{from=address}
@item The recipient addresses: @code{recipients=addr1,addr2,@dots{}}
@item The size of the mail as transferred to the server, in bytes (only if the
delivery succeeded): @code{mailsize=number}
@item The SMTP status code and SMTP error message (only in case of
failure and only if available): @code{smtpstatus=number},
@code{smtpmsg='message'}. Multiline SMTP messages will be concatenated into one
line.
@item The msmtp error message (only in case of failure and only
if available): @code{errormsg='message'}
@item The msmtp exit code (from @code{sysexits.h}; @samp{EX_OK} indicates
success): @code{exitcode=EX_@dots{}}
@end itemize
If a logfile is given with the @samp{logfile} command or @samp{--logfile}
option, this log line will be prepended with the current date and time and
appended to the specified file. See @ref{logfile}, @ref{--logfile}.
If syslog logging is enabled with the @samp{syslog} command or @samp{--syslog}
option, the log line is passed to the syslog service with the specified
facility. See @ref{syslog}, @ref{--syslog}.
@node Bcc header
@section Bcc header
msmtp transmits mails unaltered to the SMTP server, with one exception: the Bcc
header(s) will be removed before the transmission. This behavior can be changed
with the @samp{keepbcc} command and @samp{--keepbcc} option, see
@ref{keepbcc}/@ref{--keepbcc}.
@node Server information mode
@chapter Server information mode
In server information mode, msmtp prints as much information about the SMTP
server as it can get and then exits.
The SMTP features that can be detected are:
@itemize
@item SIZE@*
The maximum message size that the SMTP server accepts.
@item PIPELINING@*
Whether certain SMTP commands may be send in groups rather than one by one.
This can speed up mail transmission if the recipient list is long.
This feature is used automatically.
@item STARTTLS@*
@xref{Transport Layer Security}.
@item AUTH@*
@xref{Authentication}.
@item DSN@*
@xref{Delivery Status Notifications}.
@item ETRN@*
@xref{Remote Message Queue Starting mode}.
@end itemize
If TLS is activated for server information mode, the following information will
be printed about the SMTP server's TLS certificate (if available):
@itemize
@item Owner information
@itemize
@item Common Name
@item Organization
@item Organizational unit
@item Locality
@item State or Province
@item Country
@end itemize
@item Issuer information
@itemize
@item Common Name
@item Organization
@item Organizational unit
@item Locality
@item State or Province
@item Country
@end itemize
@item General
@itemize
@item Activation time
@item Expiration time
@item SHA1 fingerprint
@item MD5 fingerprint
@end itemize
@end itemize
@node Remote Message Queue Starting mode
@chapter Remote Message Queue Starting mode
Remote Message Queue Starting (RMQS) is defined in RFC 1985. It is a way for a
client to request that a server start the processing of its mail queues for
messages that are waiting at the server for the client machine. If any
messages are at the server for the client, then the server creates a new SMTP
session and sends the messages at that time.
msmtp can only send the request (using the ETRN SMTP command); a mail server on
the client side should then accept the connection of the remote SMTP server to
receive the mail.
RMQS requests can be sent with the @samp{--rmqs} option (see @ref{--rmqs}).
Destinations defined in RFC 1985 are:
@itemize
@item @var{host}@*
Request the messages for the given host.
@item @var{@@domain}@*
Request the messages for the given domain.
@item @var{#queue}@*
Request the delivery of the messages in the given queue.
@end itemize
@node Examples
@chapter Examples
@menu
* A system wide configuration file::
* A user configuration file::
* Using msmtp with Mutt::
* Using msmtp with mail::
* Aliases file::
@end menu
@node A system wide configuration file
@section A system wide configuration file
@example
# A system wide configuration is optional.
# If it exists, it usually defines a default account.
# This allows msmtp to be used like /usr/sbin/sendmail.
account default
# The SMTP smarthost.
host mailhub.oursite.example
# Construct envelope-from addresses of the form "user@@oursite.example".
#auto_from on
#maildomain oursite.example
# Use TLS.
#tls on
#tls_trust_file /etc/ssl/certs/ca-certificates.crt
# Syslog logging with facility LOG_MAIL instead of the default LOG_USER.
syslog LOG_MAIL
@end example
@node A user configuration file
@section A user configuration file
@example
# Set default values for all following accounts.
defaults
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.msmtp.log
# A freemail service
account freemail
host smtp.freemail.example
from joe_smith@@freemail.example
auth on
user joe.smith
password secret
# A second mail address at the same freemail service
account freemail2 : freemail
from joey@@freemail.example
# The SMTP server of the provider.
account provider
host mail.provider.example
from smithjoe@@provider.example
auth on
user 123
passwordeval gpg -d ~/.msmtp.password.gpg
# Set a default account
account default : provider
@end example
@node Using msmtp with Mutt
@section Using msmtp with Mutt
Create a configuration file for msmtp and add the following lines to your Mutt
configuration file:
@example
set sendmail="/path/to/msmtp"
set use_from=yes
set realname="Your Name"
set from=you@@example.com
set envelope_from=yes
@end example
The @samp{envelope_from=yes} option lets Mutt use the @option{-f} option of
msmtp. Therefore msmtp chooses the first account that matches the from address
you@@example.com. Alternatively, you can use the @option{-a} option:
@example
set sendmail="/path/to/msmtp -a my_account"
@end example
Or set everything from the command line:
@example
set sendmail="/path/to/msmtp --host=mailhub -f me@@example.com --tls"
@end example
@xref{Choosing an account}.
If you have multiple mail accounts in your msmtp configuration file and let Mutt
use the @option{-f} option to choose one, you can easily switch accounts in Mutt
with the following Mutt configuration lines:
@example
macro generic "<esc>1" ":set from=you@@example.com"
macro generic "<esc>2" ":set from=you@@your-employer.example"
macro generic "<esc>3" ":set from=you@@some-other-provider.example"
@end example
Now you can use <esc>1, <esc>2, and <esc>3 to switch accounts.
The following example uses a different approach: it maps the single key
@code{<tab>} in Compose context for switching between the various account in a
handy visual way. In the same Compose context, @code{=} is mapped in order to
show the current msmtp account. This example was contributed by Thomas Baruchel.
@example
# Define <tab> and = in order to switch or see the current msmtp account
# Don't forget to put the right path for msmtp binary
macro compose \Cx_ ":set sendmail"
macro compose \Cx| "\Cx_ = \"/usr/local/bin/msmtp"
macro compose \Cx& ":macro compose \\t \\Cx"
macro compose <tab> "\Cx0"
macro compose = "\Cx_\n"
# Put the account in the following lines (here three accounts)
# Don't forget to put the number of the account at the beginning
# of the line, and the number of the next account after the '&'
macro compose \Cx0 "\Cx|\"\n\Cx&1\n\Cx_\n" # default and switch to 1
macro compose \Cx1 "\Cx| -a example_account\"\n\Cx&2\n\Cx_\n" # switch to 2
macro compose \Cx2 "\Cx| -a gmail\"\n\Cx&0\n\Cx_\n" # switch to 0
# End of the accounts
@end example
@node Using msmtp with mail
@section Using msmtp with mail
Define a default account, and put the following into @code{~/.mailrc}:
@example
set sendmail="/path/to/msmtp"
@end example
You need to define a default account, because mail does not allow extra options
to the msmtp command line.
@node Aliases file
@section Aliases file
@example
# Example aliases file
# Send root to Joe and Jane
root: joe_smith@@example.com, jane_chang@@example.com
# Send cron to Mark
cron: mark_jones@@example.com
# Send everything else to admin
default: admin@@domain.example
@end example
@bye
|