Configure Gmail SMTP as a relay host in postfix mail Server

Configure Gmail SMTP as a relay host in postfix mail Server

postfix mail server


1. Modify postfix configuration file for relay host and authentication mode

[root@localhost postfix]# vi /etc/postfix/
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
inet_interfaces = localhost
inet_protocols = ipv4
mydestination = $myhostname, localhost.$mydomain, localhost
unknown_local_recipient_reject_code = 550
relayhost = []:587
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
debug_peer_level = 2
debugger_command =
ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
[root@localhost postfix]#

2. Create username/password file for Gmail SMTP Authentication

[root@localhost postfix]# vi /etc/postfix/sasl_passwd
[root@localhost postfix]#
[root@localhost postfix]# postmap /etc/postfix/sasl_passwd
[root@localhost postfix]# chmod 600 /etc/postfix/sasl_passwd  /etc/postfix/sasl_passwd.db

3. Reload postfix configuration

[root@localhost postfix]# /etc/init.d/postfix reload
Reloading postfix: [ OK ]
[root@localhost postfix]#

4. Test email with Gmail SMTP Authentication as Relay Host

[root@localhost postfix]# mail -s test < /dev/null
Null message body; hope that’s ok
[root@localhost postfix]#

That’s all. Thanks for using


Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>