22 August 2014

If an application wants to send mail out, besides you have to config your application correctly, you have to install mail server on localhost. The localhost mail server will finially send mails to and mail replay.

We use postfix as localhost mail server here. First, change hostname to match the domain of the localhost SMTP server. Suppose domain is testmail.com

sudo su -
# change hostname to '*.testmail.com'. here we use 'hahaha.testmail.com'
hostname hahaha.testmail.com
vim /etc/hosts
append " hahaha.testmail.com" to line " ..."
vim /etc/sysconfig/network
change HOSTNAME to "HOSTNAME=hahaha.testmail.com"

Config postfix. To troubleshoot check /var/log/maillog

sudo su -
# config postfix
vim /etc/postfix/main.cf
  myorigin = $mydomain
  inet_interfaces = all
  mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
  relay_domains = $mydestination, mail.public.com
  relayhost = # it is on domain "mail.public.com"
  debug_peer_level = 10
# optionally, to enable logging mail subjects
vim /etc/postfix/main.cf
  header_checks = regexp:/etc/postfix/header_checks
vim /etc/postfix/header_checks
  /^subject:/ WARN

Restart postfix

service postfix restart

Next, we need the next mail relay to accept our mails. Ask owner of to allow our access.

Create an Issue or comment below