How to configure postfix to send mail with smtp server


This document presents how to configure postfix to send e-mail as named " trasport"  on postfix configuration.  You can send e-mail to configure  SMTP server on postfix configuration.

Step 1: Check your  current  postfix configuration

# postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
html_directory = no
inet_interfaces = localhost
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
transport_maps = hash:/etc/postfix/transport
unknown_local_recipient_reject_code = 550

Step 2: Edit  main.cf  config file

*You should edit  main.cf  config  file which is located under "/etc/postfix/" directory. Open main.cf  file with  "vi"  command and add transport option to the last line of config file.

#vi  /etc/postfix/main.cf
transport_maps =  hash:/etc/postfix/transport

Step 3:Edit  transport config  file.

Also, you need to create a  transport file. Just  open transport file under "/etc/postfix" and find "my.domain"  line and add your SMTP server.

#vi /etc/postfix/transport

# my.domain :
# .my.domain :
# * smtp:outbound-relay.my.domain
* smtp:smtpserver

Step 4: Create transport.db  file

# pwd
/etc/postfix
[root@tokendb1 postfix]# postmap transport
[root@tokendb1 postfix]#
[root@tokendb1 postfix]#
[root@tokendb1 postfix]#
[root@tokendb1 postfix]# ls -lrt
total 152
-rw-r--r--. 1 root root 12494 Feb 13 2014 virtual
-rw-r--r--. 1 root root 6816 Feb 13 2014 relocated
-rw-r--r--. 1 root root 5113 Feb 13 2014 master.cf
-rw-r--r--. 1 root root 18287 Feb 13 2014 header_checks
-rw-r--r--. 1 root root 9904 Feb 13 2014 generic
-rw-r--r--. 1 root root 11681 Feb 13 2014 canonical
-rw-r--r--. 1 root root 19579 Feb 13 2014 access
-rw-r--r-- 1 root root 27060 Feb 29 08:31 main.cf
-rw-r--r-- 1 root root 12533 Feb 29 08:33 transport
-rw-r--r-- 1 root root 12288 Feb 29 08:35 transport.db

Step 5: Restart postfix service.

# service postfix restart
Shutting down postfix: [ OK ]
Starting postfix: [ OK ]

 

*Send  a test e-mail

# echo 'hi'|mailx  -s  'test'  abdurrahim.yildirim@casesup.com

 

Tagged In:

I'm a IT Infrastructure and Operations Architect with extensive experience and administration skills and works for Turk Telekom. I provide hardware and software support for the IT Infrastructure and Operations tasks.

205 Total Posts
Follow Me