Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
doc:howto:smtp.client [2016/04/18 19:11] – [Example] lizbydocs:guide-user:services:email:smtp.client [2024/10/14 23:41] – [Configuration] bartprokop
Line 5: Line 5:
 ===== Overview ===== ===== Overview =====
  
-The table below is based on Chaos Calmer (15.05).+The table shows all clients ported to OpenWrt:
  
-^ Name ^ Version ^ Dependencies ^ Size ^ Features  +^ Name                                             ^ Version                    ^ Dependencies                                      ^ Size    ^ Features                                                                                                                                                                             
-msmtp | 1.6.2-1 | //libopenssl//  37785 | SSL, smarthost only, sendmail-compatible, SMTP auth | +[[docs:techref:busybox|BusyBox]] sendmail        | 1.33 //must be compiled//  | //libopenssl//                                    | 14KB   | SSL, smarthost only, sendmail-compatible, SMTP auth                                                                                                                                  | 
-| msmtp-nossl | 1.6.2-1  33503 | smarthost only, sendmail-compatible, SMTP auth | +| [[packages:pkgdata:msmtp]]                       1.8                        | //libgnutls//                                     51KB   | SSL, smarthost only, sendmail-compatible, SMTP auth                                                                                                                                  
-| mailsend | 1.17b15-2 | //libopenssl//  36679 | SSL, smarthost only, no configuration required, MIME, attachements, IPv6, SMTP auth | +[[packages:pkgdata:msmtp-nossl]]                 | 1.8                                                                          47KB   | smarthost only, sendmail-compatible, SMTP auth                                                                                                                                       
-| mailsend-nossl | 1.17b15-2  34865 | smarthost only, no configuration required, MIME, attachements, IPv6, SMTP auth  +[[packages:pkgdata:mailsend]]                    | 1.19                       | //libopenssl//                                    39KB   | SSL, smarthost only, no configuration required, MIME, attachements, IPv6, SMTP auth                                                                                                  
-| ssmtp | 2.64-1.1 | //libopenssl//11669 | SSL support, smarthost only, SMTP auth | +[[packages:pkgdata:mailsend-nossl]]              | 1.19                                                                         37KB   | smarthost only, no configuration required, MIME, attachements, IPv6, SMTP auth                                                                                                       
-| mini-sendmail | //not present on CC// | | 4726 | smarthost only, no configuration required |+[[packages:pkgdata_owrt18_6:ssmtp]]              | 2.64                       | //libopenssl//                                    11KB   | SSL support, smarthost only, SMTP auth. No longer available since OpenWRT 21                                                                                                      
 +| mini-sendmail                                    | //no package//                                                      5KB    | smarthost only, no configuration required. No longer available since OpenWRT 17                                                                                                                                           | 
 +| [[packages:pkgdata:emailrelay]]                  | 2.3                        | //libc// //libssp// //libopenssl// //libstdcpp//  | 350KB  | SMTP proxy and store-and-forward message transfer agent (MTA); can be used similar to postfix with mail queue in combination with msmtp and mutt. In v2.5 can deliver mail directly. See [[:docs:guide-user:services:email:emailrelay]] 
 +| [[docs:guide-user:services:email:xmail|XMail ]]  | //no package//    | //libopenssl//                                    |                                                                                                                                                                                              |
  
-"smarthost only" means that the program is only capable to send email through a configured "smarthost", that is, it cannot directly deliver to the destination SMTP server.+"smarthost only" means that the program is only capable to send email through a configured "smarthost", that is, it cannot directly deliver to the destination SMTP server. E.g. it won't make a DNS lookup of the email address for MX record.
  
 ===== Using mailsend ===== ===== Using mailsend =====
Line 27: Line 30:
 Being quite lightweight and not requiring any configuration, mailsend is ideal for sending mails in shell scripts. Being quite lightweight and not requiring any configuration, mailsend is ideal for sending mails in shell scripts.
  
 +[[https://github.com/muquit/mailsend]] - Sources and issues
 ==== Installation ==== ==== Installation ====
  
 Depending on whether you want SSL support or not (actually, the size of libopenssl will probably be the decisive factor), install one of the two versions: Depending on whether you want SSL support or not (actually, the size of libopenssl will probably be the decisive factor), install one of the two versions:
  
-<code>opkg install mailsend</code> +<code> 
-<code>opkg install mailsend-nossl</code>+opkg install mailsend 
 +opkg install mailsend-nossl 
 +</code>
  
 ==== Usage ==== ==== Usage ====
Line 62: Line 68:
  
 Since msmtp understands standard sendmail options, it can be used in places where sendmail is expected (e.g. PHP code). Since msmtp understands standard sendmail options, it can be used in places where sendmail is expected (e.g. PHP code).
 +
 +[[https://marlam.de/msmtp/|Official site]] - Sources and documentation
  
 ==== Installation ==== ==== Installation ====
-<code>opkg install msmtp</code>+<code>opkg install msmtp-mta</code> 
 +Installing ''%%msmtp-mta%%'' package will also create necessary ''%%sendmail%%'' symlink. If you do not need ''%%sendmail%%'' command (unlikely) then install only ''%%msmtp%%'' package.
  
 ==== Configuration ==== ==== Configuration ====
 +For router configuration, you very likely do not want to receive emails to local mailboxes. Define aliases file ''%%/etc/aliases.msmtp%%'' to send all local mails to your admin email:
 +
 +<code>
 +default: admin@example.com
 +</code>
 +
 Place your configuration in ''%%/etc/msmtprc%%''. There is an existing ''%%default%%''-block in the included config file so if you want to call ''%%msmtp%%'' without specifying an account, then you need to rename the existing ''%%default%%''-block to something else. Place your configuration in ''%%/etc/msmtprc%%''. There is an existing ''%%default%%''-block in the included config file so if you want to call ''%%msmtp%%'' without specifying an account, then you need to rename the existing ''%%default%%''-block to something else.
  
-Here is an example configuration using Fastmail's servers:+Here is an example configuration using Gmail that worlks with 2FA and an app password:
  
 <code> <code>
-# Example for a system wide configuration file +# A system wide configuration file. 
- +It defines a default account.
-# A system wide configuration file is optional+
-If it exists, it usually defines a default account.+
 # This allows msmtp to be used like /usr/sbin/sendmail. # This allows msmtp to be used like /usr/sbin/sendmail.
-account previous_default 
  
-The SMTP smarthost+Set default values
-host mailhub.oursite.example +defaults 
- +aliases /etc/aliases.msmtp
-# 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 syslog LOG_MAIL
-#//////DEFAULT END////// 
- 
- 
-account default 
- 
-host mail.messagingengine.com 
-from something@your-domain.tld 
  
 +# Gmail configuration that works with 2FA and an app password.
 +# Use TLS on port 465. On this port, TLS starts without STARTTLS.
 +account gmail
 +host smtp.gmail.com
 +port 465
 auth on auth on
-user something@your-domain.tld 
-password your-password-here 
- 
 tls on tls on
 tls_starttls off tls_starttls off
 +from_full_name Apartment Router
 +from home.lab@gmail.com
 +user home.lab@gmail.com
 +password abcd efgh ijkl mnop
 +
 +# Select the default account
 +account default : gmail
 </code> </code>
  
-The part below ''%%#//////DEFAULT END//////%%'' contains our changes with the exception of the line ''%%account previous_default%%'', which was originally ''%%account default%%''.+Now symlink ''%%msmtp%%'' to ''%%sendmail%%'' with ''%%ln -s /usr/bin/msmtp /usr/sbin/sendmail%%'' - this is not necessary if ''%%msmtp-mta%%'' was installed instead of ''%%msmtp%%''.
  
-Unless you happen to use Fastmail, replace ''%%mail.messagingengine.com%%'' with whatever the IMAP server address for your provider is. You might also need to enable the ''%%tls_starttls%%'' option.+Also you may configure env variables ''EMAIL'' for From address and ''SMTPSERVER'' to specify smarthost.
  
 ==== Sending mail ==== ==== Sending mail ====
-<code>echo -e "Subject: Test mail\n\nThis is a test \"message\"." | sendmail -f "Sender's Name <something@your-domain.tld>" recipient@destination.tld</code>+<code> 
 +echo -e "Subject: Test mail\n\nThis is a test \"message\"." | sendmail -f "<something@your-domain.tld>" "<recipient@destination.tld>" 
 +</code>
  
 Note that //sendmail// (''%%/usr/sbin/sendmail%%'') is a symlink to ''%%/usr/bin/msmtp%%''. Note that //sendmail// (''%%/usr/sbin/sendmail%%'') is a symlink to ''%%/usr/bin/msmtp%%''.
Line 125: Line 132:
 | mini-sendmail  |  1.3.6-4  |  //none//  |   5866 | mini_sendmail reads its standard input up to an end-of-file and sends a copy of the message found there to all of the addresses listed. The message is sent by connecting to a local SMTP server. This means ''mini_sendmail'' can be used to send email from inside a chroot(2) area.  | | mini-sendmail  |  1.3.6-4  |  //none//  |   5866 | mini_sendmail reads its standard input up to an end-of-file and sends a copy of the message found there to all of the addresses listed. The message is sent by connecting to a local SMTP server. This means ''mini_sendmail'' can be used to send email from inside a chroot(2) area.  |
  
 +[[https://acme.com/software/mini_sendmail/|Official site]]
 ==== Installation and Configuration ==== ==== Installation and Configuration ====
  
Line 132: Line 139:
 On Chaos Calmer, the package is no longer available, but the version from Barrier Breaker still works (AA & BB versions as installed below work in AA): On Chaos Calmer, the package is no longer available, but the version from Barrier Breaker still works (AA & BB versions as installed below work in AA):
  
-<code>opkg install http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/oldpackages/mini-sendmail_1.3.6-4_ar71xx.ipk</code>+<code> 
 +opkg install http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/oldpackages/mini-sendmail_1.3.6-4_ar71xx.ipk 
 +</code>
  
 ==== Example ==== ==== Example ====
-|<code bash>+<code bash>
 mini_sendmail -ssmtp.mail.yahoo.com -p465 -t foo@example.com < input_file mini_sendmail -ssmtp.mail.yahoo.com -p465 -t foo@example.com < input_file
  
 usage: mini_sendmail [-f<name>] [-t] [-s<server>] [-p<port>] [-T<timeout>] [-v] [address ...] usage: mini_sendmail [-f<name>] [-t] [-s<server>] [-p<port>] [-T<timeout>] [-v] [address ...]
-</code> |+</code>
  
 Note that there must not be a space between the option and the value; e.g. "-p 465" is incorrect. Note that there must not be a space between the option and the value; e.g. "-p 465" is incorrect.
  
 Several sample configurations found on the internet failed, but as of 160413, this worked Several sample configurations found on the internet failed, but as of 160413, this worked
-|<code bash> +<code bash> 
 echo -e 'From: valid@email.com\r\nSubject: Test Subject\r\n\r\nTesting\r\n.' | mini_sendmail -fvalid@email.com -smail.brighthouse.com toAddr@gmail.com echo -e 'From: valid@email.com\r\nSubject: Test Subject\r\n\r\nTesting\r\n.' | mini_sendmail -fvalid@email.com -smail.brighthouse.com toAddr@gmail.com
-</code> |+</code>
 smtp.gmail.com failed; omitting -f failed; omitting "From: " resulted in transmission, but no sender shown. smtp.gmail.com failed; omitting -f failed; omitting "From: " resulted in transmission, but no sender shown.
  
 This is a very small package if you can find an smtp server which works and you can configure the command so that the server accepts it. This is a very small package if you can find an smtp server which works and you can configure the command so that the server accepts it.
 +
 ===== Using ssmtp ===== ===== Using ssmtp =====
 +
 +[[https://tracker.debian.org/pkg/ssmtp|Official site]]
  
 ==== Description ==== ==== Description ====
Line 170: Line 182:
 ssmtp expects its two configuration files named ''/etc/ssmtp/revaliases'' and ''/etc/ssmtp/ssmtp.conf''. Both are self-explaining: ssmtp expects its two configuration files named ''/etc/ssmtp/revaliases'' and ''/etc/ssmtp/ssmtp.conf''. Both are self-explaining:
  
-|<code>+<code>
 # /etc/ssmtp/ssmtp.conf # /etc/ssmtp/ssmtp.conf
 root=arnold@gmx.net root=arnold@gmx.net
Line 179: Line 191:
 UseTLS=YES UseTLS=YES
 #UseSTARTTLS=YES #UseSTARTTLS=YES
-</code>|+</code>
  
-|<code>+<code>
 # /etc/ssmtp/revaliases # /etc/ssmtp/revaliases
 # Format: local_account:outgoing_address:mailhub # Format: local_account:outgoing_address:mailhub
 root:arnold@gmx.net:mail.gmx.net:465 root:arnold@gmx.net:mail.gmx.net:465
-</code>|+</code
  
 To use the program, with SMTP auth: To use the program, with SMTP auth:
Line 191: Line 203:
 <code bash> <code bash>
 cat /etc/banner | ssmtp -vvv -auultranerd@universum.tb -ap123password456 someguy@gmx.net cat /etc/banner | ssmtp -vvv -auultranerd@universum.tb -ap123password456 someguy@gmx.net
-</code>|+</code> 
 + 
 + 
 +===== Using BusyBox sendmail ===== 
 + 
 +  - [[https://busybox.net/downloads/BusyBox.html#sendmail|Documentation]] 
 +  - [[https://git.busybox.net/busybox/tree/mailutils/sendmail.c|Sources]] 
 + 
 +==== Description ==== 
 + 
 +The BusyBox sendmail is a smallest possible implementation but it must be compiled. It works only in smarthost mode. 
 + 
 +==== Installation ==== 
 + 
 +Enable the applet during compilation in menuconfig: ''BusyBox options'',  ''Mail'' and ''sendmail''
 +Additionally you may want to enable [[https://busybox.net/downloads/BusyBox.html#makemime|makemime]] applet that helps to send files with attachments. 
 + 
 +==== Usage ==== 
 +You need to configure ''SMTPHOST'' env variable with the smarthost SMTP server to use. 
 +Instead of the variable you may use an option ''-S server[:port]'' to specify the SMTP server. 
 + 
 +You may also need ''SMTP_ANTISPAM_DELAY'' env to bypass the Greylisting antispam if it enabled for submission. 
 + 
  • Last modified: 2024/12/14 23:20
  • by stokito