GNU/Linux Desktop Survival Guide
by Graham Williams |
|||||
Email Server using Postfix SMTP |
20201201 Postfix is a standard SMTP server that is easy to setup for sending email from your server. It can also be set up to use another authenticated server, referred to as a smarthost, to send your email, as covered in Section 24.3. Many cloud providers will block a virtual server on their cloud from sending email directly to avoid spammers using these services.
$ wajig install postfix Internet Site System mail name: crisp.net.au |
The typical settings for a local host to send email using SMTP, as stored in /etc/postfix/main.cf is created. Further settings can be configure using the reconfigure command:
$ wajig reconfigure postfix [...] Root and postmaster mail recipient: support@crisp.net.au Accept mail: .... crisp.net.au Synchronous updates: No Local networks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 Mailbox size limit: 0 Local address extension character: + Internet protocols to use: all |
The configuration as in /etc/postfix/main.cf might look like:
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) biff = no append_dot_mydomain = no readme_directory = no compatibility_level = 2 smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key smtpd_tls_security_level=may smtp_tls_CApath=/etc/ssl/certs smtp_tls_security_level=may smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination myhostname = crisp alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = crisp, 132.5.6.12, crisp, localhost.localdomain, localhost, crisp.net.au relayhost = mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all inet_protocols = all |
To check the server is active:
$ sudo netstat -tulpn | grep :25 tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 21658/master tcp6 0 0 :::25 :::* LISTEN 21658/master $ echo "This is a test email." \ | mail -s "Subject" -a "From: webmaster@crisp.net.au" fred@togaware.com $ sudo tail -f /var/log/mail.log $ sudo journalctl -u postfix |
Resources include: