Step 1: $ sudo apt-get install postfix
Postfix configuration screen throws you with the following options to choose from i) No changes (no changes to configuration settings) ii) Internet site (Mail sent and received using SMTP) iii) Internet with smarthost (Mail sent to another machine called smarthost) iV) Satellite system (All mail sent to another machine for delivery) v) Local only (No network based mail system. Only applied to this local machine)
For this example let us choose the option (iv) where we have a Linux server connected to external network through another server.
Step 2: sudo dpkg-reconfigure postfix
Next screen will ask you for the "System mail name". Give the name of the mail server in this location. Go with the default options.
To test if the configuration has gone through successfully I have used two methods. One using telnet and other using sendmail program.
root@server:/# telnet mail-server 25 Trying 192.168.1.11... Connected to mail-server.domain.com. Escape character is '^]'. 220 mailserver.domain.com Microsoft ESMTP MAIL Service, Version: 6.0.3790.3959 ready at Thu, 6 Aug 2009 12:36:38 -0400 helo gmail.com 250 mail.domain.com Hello [192.168.1.116] mail from: tester@gmail.com 250 2.1.0 tester@gmail.com....Sender OK rcpt to:receiver@gmail.com 250 2.1.5 receiver@gmail.com data 354 Start mail input; end with <CRLF>.<CRLF> testing email to google output , yes . 250 2.6.0 Queued mail for delivery quit 221 2.0.0 mail.domain.com Service closing transmission channel Connection closed by foreign host.
For further modification to the configuration you can edit /etc/postfix/main.cf file
~ Sample main.cf configuration ~
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) biff = no
# appending .domain is the MUA's job. append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings #delay_warning_time = 4h
readme_directory = no
# TLS parameters smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key smtpd_use_tls=yes smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for # information on enabling SSL in the smtp client.
myhostname = linuxserver.domain.com alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases mydestination = relayhost = mail-server.domain.com mynetworks = 127.0.0.0/8 192.168.1.0/24 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = loopback-only inet_protocols = ipv4 myorigin = /etc/mailname
Another way to check if mail is working or not is to use the sendmail program in verbose mode $ sendmail -v 'tester@gmail.com' This is a test email<CRLF>.<CRLF>
Reference: http://www.rdpslides.com/webresources/FAQ00035.htm http://pccicla.blogspot.com/2007/02/ubuntu-smtp-server.html