1MSMTP(1) General Commands Manual MSMTP(1)
2
3
4
6 msmtp - An SMTP client
7
9 Sendmail mode (default):
10 msmtp [option...] [--] recipient...
11 msmtp [option...] -t [--] [recipient...]
12
13 Server information mode:
14 msmtp [option...] --serverinfo
15
16 Remote Message Queue Starting mode:
17 msmtp [option...] --rmqs=host|@domain|#queue
18
20 In the default sendmail mode, msmtp reads a mail from standard input
21 and sends it to an SMTP server for delivery.
22 In server information mode, msmtp prints information about an SMTP
23 server.
24 In Remote Message Queue Starting mode, msmtp sends a Remote Message
25 Queue Starting request for a host, domain, or queue to an SMTP server.
26
28 The standard sendmail exit status codes are used, as defined in sysex‐
29 its.h.
30
32 Options override configuration file settings.
33 They are compatible with sendmail where appropriate.
34
35 General options
36
37 --version
38 Print version information. This includes information
39 about the library used for TLS/SSL support (if any), the
40 library used for authentication, the authentication mech‐
41 anisms supported by this library, and the default loca‐
42 tions of the system and user configuration files.
43
44 --help Print help.
45
46 -P, --pretend
47 Print the configuration settings that would be used, but
48 do not take further action. An asterisk ('*') will be
49 printed instead of your password.
50
51 -v, -d, --debug
52 Print lots of debugging information, including the whole
53 conversation with the SMTP server. Be careful with this
54 option: the (potentially dangerous) output will not be
55 sanitized, and your password may get printed in an easily
56 decodable format!
57
58 Changing the mode of operation
59
60 -S, --serverinfo
61 Print information about the SMTP server and exit. This
62 includes information about supported features (mail size
63 limit, authentication, TLS, DSN, ...) and about the TLS
64 certificate (if TLS is active).
65
66 --rmqs=(host|@domain|#queue)
67 Send a Remote Message Queue Starting request for the
68 given host, domain, or queue to the SMTP server and exit.
69
70 Configuration options
71
72 -C, --file=filename
73 Use the given file instead of ~/.msmtprc as the user con‐
74 figuration file.
75
76 -a, --account=account_name
77 Use the given account instead of the account named
78 "default". The settings of this account may be changed
79 with command line options. This option cannot be used
80 together with the --host option.
81
82 --host=hostname
83 Use this SMTP server with settings from the command line;
84 do not use any configuration file data. This option can‐
85 not be used together with the --account option.
86
87 --port=number
88 Set the port number to connect to. See the port command
89 below.
90
91 --timeout=(off|seconds)
92 Set a network timeout. See the timeout command below. For
93 compatibility with older versions, --connect-timeout is
94 accepted as an alias for this option.
95
96 --protocol=(smtp|lmtp)
97 Set the protocol to use. See the protocol command below.
98
99 --auth[=(on|off|method)]
100 Enable or disable authentication. You can optionally
101 choose the method. See the auth command below.
102
103 --user=[username]
104 Set or unset the user name for authentication. See the
105 user command below.
106
107 --tls[=(on|off)]
108 Enable or disable TLS/SSL encryption. See the tls command
109 below.
110
111 --tls-starttls[=(on|off)]
112 Enable or disable STARTTLS for TLS encryption. See the
113 tls_starttls command below.
114
115 --tls-trust-file=[file]
116 Set or unset a trust file for TLS encryption. See the
117 tls_trust_file command below.
118
119 --tls-crl-file=[file]
120 Set or unset a certificate revocation list (CRL) file for
121 TLS. See the tls_crl_file command below.
122
123 --tls-key-file=[file]
124 Set or unset a key file for TLS encryption. See the
125 tls_key_file command below.
126
127 --tls-cert-file=[file]
128 Set or unset a cert file for TLS encryption. See the
129 tls_cert_file command below.
130
131 --tls-certcheck[=(on|off)]
132 Enable or disable server certificate checks for TLS
133 encryption. See the tls_certcheck command below.
134
135 --tls-force-sslv3[=(on|off)]
136 Force TLS/SSL version SSLv3. See the tls_force_sslv3 com‐
137 mand below.
138
139 --tls-min-dh-prime-bits=[bits]
140 Set or unset minimum bit size of the Diffie-Hellman (DH)
141 prime. See the tls_min_dh_prime_bits command below.
142
143 --tls-priorities=[priorities]
144 Set or unset TLS priorities. See the tls_priorities com‐
145 mand below.
146
147 --domain=[string]
148 Set the argument of the SMTP EHLO (or LMTP LHLO) command.
149 See the domain command below.
150
151 Options specific to sendmail mode
152
153 --auto-from[=(on|off)]
154 Enable or disable automatic envelope-from addresses. The
155 default is off. See the auto_from command below.
156
157 -f, --from=address
158 Set the envelope-from address. It is only used when
159 auto_from is off.
160 If no account was chosen yet (with --account or --host),
161 this option will choose the first account that has the
162 given envelope-from address (set with the from command).
163 If no such account is found, "default" is used.
164
165 --maildomain=[domain]
166 Set the domain part for generated envelope-from
167 addresses. It is only used when auto_from is on. See the
168 maildomain command below.
169
170 -N, --dsn-notify=(off|cond)
171 Set or unset DSN notification conditions. See the
172 dsn_notify command below.
173
174 -R, --dsn-return=(off|ret)
175 Set or unset the DSN notification amount. See the
176 dsn_return command below. Note that hdrs is accepted as
177 an alias for headers to be compatible with sendmail.
178
179 --keepbcc[=(on|off)]
180 Enable or disable the preservation of the Bcc header. See
181 the keepbcc command below.
182
183 -X, --logfile=[file]
184 Set or unset the log file. See the logfile command below.
185
186 --syslog[=(on|off|facility)]
187 Enable or disable syslog logging. See the syslog command
188 below.
189
190 -t, --read-recipients
191 Read recipient addresses from the To, Cc, and Bcc headers
192 of the mail in addition to the recipients given on the
193 command line. If any Resent- headers are present, then
194 the addresses from any Resent-To, Resent-Cc, and Resent-
195 Bcc headers in the first block of Resent- headers are
196 used instead.
197
198 --read-envelope-from
199 Read the envelope from address from the From header of
200 the mail.
201
202 -- This marks the end of options. All following arguments
203 will be treated as recipient addresses, even if they
204 start with a '-'.
205
206 The following options are accepted but ignored for sendmail compatibil‐
207 ity:
208 -Btype, -bm, -Fname, -G, -hN, -i, -L tag, -m, -n, -O option=value, -ox
209 value
210
212 Normally, a system wide configuration file and/or a user configuration
213 file contain information about which SMTP server to use (and how to use
214 it), but almost all settings can also be configured on the command
215 line.
216
217 Information about SMTP servers is organized in accounts. Each account
218 describes one SMTP server: host name, authentication settings, TLS set‐
219 tings, and so on. Each configuration file can define multiple
220 accounts.
221
222 In sendmail mode, an envelope-from address is necessary to send mail.
223 This is the mail address that will be presented to the SMTP server as
224 the originator of the mail. Envelope-from addresses can be generated
225 automatically (when auto_from is enabled) or set explicitly with the
226 from command or --from option. When auto_from is enabled, an envelope-
227 from address of the form user@domain will be generated. The local part
228 will be set to USER or, if that fails, to LOGNAME or, if that fails, to
229 the login name of the current user. The domain part can be set with
230 the maildomain command. If the maildomain is empty, the envelope-from
231 address will only consist of the user name and not have a domain part.
232
233 The user can choose which account to use in one of three ways:
234
235 --account=id
236 Use the given account. Command line settings override configura‐
237 tion file settings.
238
239 --host=hostname
240 Use only the settings from the command line; do not use any con‐
241 figuration file data.
242
243 --from=address or --read-envelope-from
244 Choose the first account from the system or user configuration
245 file that has a matching envelope-from address as specified by a
246 from command. This works only when neither --account nor --host
247 is used.
248
249 If none of the above options is used (or if no account has a matching
250 from command), then the account "default" is used.
251
252 Skip to the EXAMPLES section for a quick start.
253
255 If it exists and is readable, a system wide configuration file
256 SYSCONFDIR/msmtprc will be loaded, where SYSCONFDIR depends on your
257 platform. Use --version to find out which directory is used.
258 If it exists and is readable, a user configuration file will be loaded
259 (~/.msmtprc by default). Accounts defined in the user configuration
260 file override accounts from the system configuration file. The user
261 configuration file must have no more permissions than user read/write.
262 Configuration data from either file can be changed by command line
263 options.
264
265 A configuration file is a simple text file. Empty lines and comment
266 lines (whose first non-blank character is '#') are ignored.
267 Every other line must contain a command and may contain an argument to
268 that command.
269 The argument may be enclosed in double quotes ("), for example if its
270 first or last character is a blank.
271 If the first character of a filename is the tilde (~), this tilde will
272 be replaced by HOME. If a command accepts the argument on, it also
273 accepts an empty argument and treats that as if it was on.
274 Commands form groups. Each group begins with the account command and
275 defines the settings for one SMTP server.
276
277 Skip to the EXAMPLES section for a quick start.
278
279 Commands are as follows:
280
281 defaults
282 Set defaults. The following configuration commands will set
283 default values for all following account definitions in the cur‐
284 rent configuration file.
285
286 account name [:account[,...]]
287 Start a new account definition with the given name. The current
288 default values are filled in.
289 If a colon and a list of previously defined accounts is given
290 after the account name, the new account, with the filled in
291 default values, will inherit all settings from the accounts in
292 the list.
293
294 host hostname
295 The SMTP server to send the mail to. The argument may be a host
296 name or a network address. Every account definition must con‐
297 tain this command.
298
299 port number
300 The port that the SMTP server listens on. The default port will
301 be acquired from your operating system's service database: for
302 SMTP, the service is "smtp" (default port 25), unless TLS with‐
303 out STARTTLS is used, in which case it is "ssmtp" (465). For
304 LMTP, it is "lmtp".
305
306 timeout (off|seconds)
307 Set or unset a network timeout, in seconds. The argument off
308 means that no timeout will be set, which means that the operat‐
309 ing system default will be used.
310 For compatibility with older versions, connect_timeout is
311 accepted as an alias for this command.
312
313 protocol (smtp|lmtp)
314 Set the protocol to use. Currently only SMTP and LMTP are sup‐
315 ported. SMTP is the default. See the port command above for
316 default ports.
317
318 auto_from [(on|off)]
319 Enable or disable automatic envelope-from addresses. The default
320 is off. When enabled, an envelope-from address of the form
321 user@domain will be generated. The local part will be set to
322 USER or, if that fails, to LOGNAME or, if that fails, to the
323 login name of the current user. The domain part can be set with
324 the maildomain command. If the maildomain is empty, the enve‐
325 lope-from address will only consist of the user name and not
326 have a domain part. When auto_from is disabled, the envelope-
327 from address must be set explicitly.
328
329 from envelope_from
330 Set the envelope-from address. This address will only be used
331 when auto_from is off.
332
333 maildomain [domain]
334 Set a domain part for the generation of an envelope-from
335 address. This is only used when auto_from is on. The domain may
336 be empty.
337
338 auth [(on|off|method)]
339 This command enables or disables SMTP authentication. You should
340 not need to set the method yourself; with the argument on, msmtp
341 will choose the best one available for you (see below).
342 You probably need to set a username (with user) and password
343 (with password). If no password is set but one is needed during
344 authentication, msmtp will try to find it in ~/.netrc. If that
345 fails, it will try to find it in SYSCONFDIR/netrc (use --version
346 to find out what SYSCONFDIR is on your platform). If that fails,
347 it will try to get it from a system specific keychain (if avail‐
348 able). If that fails but a controlling terminal is available,
349 msmtp will prompt you for it.
350 Currently supported keychains are the GNOME keychain and the Mac
351 OS X keychain. See the EXAMPLES section below.
352 Available methods are plain, cram-md5, digest-md5, gssapi,
353 external, login, and ntlm. Note that one or more of these meth‐
354 ods may be unavailable due to lack of support in the underlying
355 authentication library. Use the --version option to find out
356 which methods are supported.
357 The plain and login methods send your authentication data in
358 cleartext over the net, and the ntlm method may be vulnerable to
359 attacks. These methods should therefore only be used together
360 with the tls command.
361 If you don't choose the method yourself, msmtp chooses the best
362 secure method that the SMTP server supports. Secure means that
363 your authentication data will not be sent in cleartext over the
364 net. For TLS encrypted connections, every authentication method
365 is secure in this sense. If TLS is not active, only gssapi,
366 digest-md5, and cram-md5 are secure in this sense.
367 The external is special: the actual authentication happens out‐
368 side of the SMTP protocol, typically by sending a TLS client
369 certificate (see the tls_cert_file command). The external method
370 merely confirms that this authentication succeeded for the given
371 user (or, if no user name is given, confirms that authentication
372 succeeded). This authentication method is not chosen automati‐
373 cally; you have to request it manually.
374
375 user [username]
376 Set your user name for SMTP authentication. An empty argument
377 unsets the user name. Authentication must be activated with the
378 auth command.
379
380 password [secret]
381 Set your password for SMTP authentication. An empty argument
382 unsets the password. Authentication must be activated with the
383 auth command. If no password is set but one is needed during
384 authentication, msmtp will try to find it in ~/.netrc. If that
385 fails, it will try to find it in SYSCONFDIR/netrc (use --version
386 to find out what SYSCONFDIR is on your platform). If that fails,
387 it will try to get it from a system specific keychain (if avail‐
388 able). If that fails but a controlling terminal is available,
389 msmtp will prompt you for it.
390
391 ntlmdomain [domain]
392 Set a domain for the ntlm authentication method. The default is
393 to use no domain (equivalent to an empty argument), but some
394 servers seem to require one, even if it is an arbitrary string.
395
396 tls [(on|off)]
397 This command enables or disables TLS (also known as SSL)
398 encrypted connections to the SMTP server. Not every server sup‐
399 ports TLS.
400 With TLS/SSL, the connection with the SMTP server will be pro‐
401 tected against eavesdroppers and man-in-the-middle attacks. To
402 use TLS/SSL, it is required to either use the tls_trust_file
403 command (highly recommended) or to disable tls_certcheck.
404
405 tls_starttls [(on|off)]
406 By default, TLS encryption is activated using the STARTTLS SMTP
407 command. By disabling this, TLS encryption is immediately
408 started instead (this is known as SMTP tunneled through
409 TLS/SSL). The default port is set to 465 for this mode of opera‐
410 tion.
411 For compatibility with older versions, tls_nostarttls is
412 accepted as an alias for tls_starttls off.
413
414 tls_trust_file [file]
415 This command activates strict server certificate verification.
416 The filename must be the absolute path name of a file in PEM
417 format containing one or more certificates of trusted Certifica‐
418 tion Authorities (CAs).
419 On Debian based systems, you can install the ca-certificates
420 package and use the file /etc/ssl/certs/ca-certificates.crt.
421
422 tls_crl_file [file]
423 This command sets or unsets a certificate revocation list (CRL)
424 file for TLS, to be used during strict server certificate veri‐
425 fication as enabled by the tls_trust_file command. This allows
426 the verification procedure to detect revoked certificates.
427
428 tls_key_file [file]
429 This command (together with the tls_cert_file command) enables
430 msmtp to send a client certificate to the SMTP server if
431 requested. The file must contain the private key of a certifi‐
432 cate in PEM format. An empty argument disables this feature.
433
434 tls_cert_file [file]
435 This command (together with the tls_key_file command) enables
436 msmtp to send a client certificate to the SMTP server if
437 requested. The file must contain a certificate in PEM format.
438 An empty argument disables this feature.
439
440 tls_certcheck [(on|off)]
441 This command enables or disables checks for the server certifi‐
442 cate.
443 WARNING: When the checks are disabled, TLS/SSL sessions will be
444 vulnerable to man-in-the-middle attacks!
445 For compatibility with older versions, tls_nocertcheck is
446 accepted as an alias for tls_certcheck off.
447
448 tls_force_sslv3 [(on|off)]
449 Force TLS/SSL version SSLv3. This might be needed to use SSL
450 with some old and broken servers. Do not use this unless you
451 have to.
452
453 tls_min_dh_prime_bits [bits]
454 Set or unset the minimum number of Diffie-Hellman (DH) prime
455 bits that msmtp will accept for TLS sessions. The default is
456 set by the TLS library and can be selected by using an empty
457 argument to this command. Only lower the default (for example
458 to 512 bits) if there is no other way to make TLS work with the
459 remote server.
460
461 tls_priorities [priorities]
462 Set the priorities for TLS sessions. The default is set by the
463 TLS library and can be selected by using an empty argument to
464 this command. Currently this command only works with suffi‐
465 ciently recent GnuTLS releases. See the GnuTLS documentation of
466 the gnutls_priority_init function for a description of the pri‐
467 orities string.
468
469 dsn_notify (off|condition)
470 This command sets the condition(s) under which the mail system
471 should send DSN (Delivery Status Notification) messages. The
472 argument off disables explicit DSN requests, which means the
473 mail system decides when to send DSN messages. This is the
474 default. The condition must be never, to never request notifi‐
475 cation, or a comma separated list (no spaces!) of one or more of
476 the following: failure, to request notification on transmission
477 failure, delay, to be notified of message delays, success, to be
478 notified of successful transmission. The SMTP server must sup‐
479 port the DSN extension.
480
481 dsn_return (off|amount)
482 This command controls how much of a mail should be returned in
483 DSN (Delivery Status Notification) messages. The argument off
484 disables explicit DSN requests, which means the mail system
485 decides how much of a mail it returns in DSN messages. This is
486 the default. The amount must be headers, to just return the
487 message headers, or full, to return the full mail. The SMTP
488 server must support the DSN extension.
489
490 domain argument
491 Use this command to set the argument of the SMTP EHLO (or LMTP
492 LHLO) command. The default is localhost (stupid, but working).
493 Possible choices are the domain part of your mail address
494 (provider.example for joe@provider.example) or the fully quali‐
495 fied domain name of your host (if available).
496
497 keepbcc [(on|off)]
498 This command controls whether to remove or keep the Bcc header
499 when sending a mail. The default is to remove it.
500
501 logfile [file]
502 An empty argument disables logging (this is the default).
503 When logging is enabled by choosing a log file, msmtp will
504 append one line to the log file for each mail it tries to send
505 via the account that this log file was chosen for.
506 The line will include the following information: date and time,
507 host name of the SMTP server, whether TLS was used, whether
508 authentication was used, authentication user name (only if
509 authentication is used), envelope-from address, recipient
510 addresses, size of the mail as transferred to the server (only
511 if the delivery succeeded), SMTP status code and SMTP error mes‐
512 sage (only in case of failure and only if available), error mes‐
513 sage (only in case of failure and only if available), exit code
514 (from sysexits.h; EX_OK indicates success).
515 If the filename is a dash (-), msmtp prints the log line to the
516 standard output.
517
518 syslog [(on|off|facility)]
519 Enable or disable syslog logging. The facility can be one of
520 LOG_USER, LOG_MAIL, LOG_LOCAL0, ..., LOG_LOCAL7. The default is
521 LOG_USER.
522 Each time msmtp tries to send a mail via the account that con‐
523 tains this syslog command, it will log one entry to the syslog
524 service with the chosen facility.
525 The line will include the following information: host name of
526 the SMTP server, whether TLS was used, whether authentication
527 was used, envelope-from address, recipient addresses, size of
528 the mail as transferred to the server (only if the delivery suc‐
529 ceeded), SMTP status code and SMTP error message (only in case
530 of failure and only if available), error message (only in case
531 of failure and only if available), exit code (from sysexits.h;
532 EX_OK indicates success).
533
535 Configuration file
536
537 # Set default values for all following accounts.
538 defaults
539 tls on
540 tls_trust_file /etc/ssl/certs/ca-certificates.crt
541 logfile ~/.msmtp.log
542
543 # A freemail service
544 account freemail
545 host smtp.freemail.example
546 from joe_smith@freemail.example
547 auth on
548 user joe.smith
549 password secret
550
551 # A second mail address at the same freemail service
552 account freemail2 : freemail
553 from joey@freemail.example
554
555 # The SMTP server of the provider.
556 account provider
557 host mail.provider.example
558 from smithjoe@provider.example
559 auth on
560 user 123456789
561 password my_password
562
563 # Set a default account
564 account default : provider
565
566
567 Manually finding the right CA certificate for tls_trust_file
568
569 The following example works as of 2007-04-18.
570 For the Gmail SMTP server, you first issue the following command:
571 msmtp --serverinfo --host=smtp.gmail.com --tls=on --port=587
572 --tls-certcheck=off
573 The option --port=587 is specific to Gmail and should not be used with
574 other servers. The option --tls-certcheck=off allows msmtp to accept
575 any certificate, so that it can print some information about it.
576 According to the output of this command, the common name of the server
577 certificate issuer is "Thawte Premium Server CA". This means that you
578 have to trust the Thawte CA to use full TLS security. You can download
579 the Thawte CA certificate bundle from http://thawte.com/roots. You get
580 a ZIP file with different certificates. The one you need for the
581 tls_trust_file command is Thawte Server Roots/ThawtePremium‐
582 ServerCA_b64.txt.
583 The following command should now succeed:
584 msmtp --serverinfo --host=smtp.gmail.com --tls=on --port=587
585 --tls-trust-file="Thawte Server Roots/ThawtePremiumServerCA_b64.txt"
586
587
588 Using msmtp with Mutt
589
590 Create a configuration file for msmtp and add the following lines to
591 your Mutt configuration file:
592 set sendmail="/path/to/msmtp"
593 set use_from=yes
594 set realname="Your Name"
595 set from=you@example.com
596 set envelope_from=yes
597 The envelope_from=yes option lets Mutt use the -f option of msmtp.
598 Therefore msmtp chooses the first account that matches the from address
599 you@example.com.
600 Alternatively, you can use the -a option:
601 set sendmail="/path/to/msmtp -a my-account"
602 Or set everything from the command line:
603 set sendmail="/path/to/msmtp --host=mailhub -f me@example.com --tls"
604
605 If you have multiple mail accounts in your msmtp configuration file and
606 let Mutt use the -f option to choose the right one, you can easily
607 switch accounts in Mutt with the following Mutt configuration lines:
608 macro generic "<esc>1" ":set from=you@example.com"
609 macro generic "<esc>2" ":set from=you@your-employer.example"
610 macro generic "<esc>3" ":set from=you@some-other-provider.example"
611
612
613 Using msmtp with mail
614
615 Define a default account, and put the following in your ~/.mailrc:
616 set sendmail="/path/to/msmtp"
617
618
619 Using the Mac OS X Keychain
620
621 A Mac OS X user can store a password in a keychain item using the Key‐
622 chain Access GUI application. The account name is simply the value of
623 the msmtp user argument. However, the keychain item name is
624 smtp://<hostname> where <hostname> matches the msmtp host argument.
625 Using smtp:// is needed so that the item is created of kind internet
626 password. For example, selecting File->Get Info on a keychain item
627 that corresponds to host smtp.freemail.example and user joe.smith will
628 show:
629 Name: smtp.freemail.example
630 Kind: Internet password
631 Account: joe.smith
632 Where: smtp://smtp.freemail.example
633
635 SYSCONFDIR/msmtprc
636 System configuration file. Use --version to find out what
637 SYSCONFDIR is on your platform.
638
639 ~/.msmtprc
640 User configuration file.
641
642 ~/.netrc and SYSCONFDIR/netrc
643 The netrc file contains login information. If a password is not
644 found in the configuration file, msmtp will search it in
645 ~/.netrc and SYSCONFDIR/netrc before prompting the user for it.
646 The syntax of netrc files is described in netrc(5) or ftp(1).
647
649 USER, LOGNAME
650 These variables override the user's login name when constructing
651 an envelope-from address. LOGNAME is only used if USER is unset.
652
653 TMPDIR Directory to create temporary files in. If this is unset, a sys‐
654 tem specific default directory is used.
655 A temporary file is only created when the -t/--read-recipients
656 or --read-envelope-from option is used. The file is then used to
657 buffer the headers of the mail (but not the body, so the file
658 won't get very large).
659
660 EMAIL, SMTPSERVER
661 These environment variables are used only if neither --host nor
662 --account is used and there is no default account defined in the
663 configuration files. In this case, the host name is taken from
664 SMTPSERVER, and the envelope from address is taken from EMAIL,
665 unless overridden by --from or --read-envelope-from. Currently
666 SMTPSERVER must contain a plain host name (no URL), and EMAIL
667 must contain a plain address (no names or additional informa‐
668 tion).
669
671 msmtp was written by Martin Lambers <marlam@marlam.de>.
672 Other authors are listed in the AUTHORS file in the source distribu‐
673 tion.
674
676 mutt(1), mail(1), sendmail(8), netrc(5) or ftp(1)
677
678
679
680 2009-10 MSMTP(1)