Jumat, 02 November 2018

How to install and setting postfix for gmail relayhost mail server

  Tidak ada komentar
Install postfix and the dependency package
[root@monitoring-cloud ~]# yum -y install Postfix mailx cyrus-sasl-plain
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.biz.net.id
 * epel: del-repos.extreme-ix.org
 * extras: centos.biz.net.id
 * updates: centos.biz.net.id
No package Postfix available.
  * Maybe you meant: postfix
Package mailx-12.5-19.el7.x86_64 already installed and latest version
Package cyrus-sasl-plain-2.1.26-23.el7.x86_64 already installed and latest version
Nothing to do
[root@monitoring-cloud ~]#

Start posfix service, enable it on startup and check service status 
[root@monitoring-cloud ~]# systemctl start postfix
[root@monitoring-cloud ~]#
[root@monitoring-cloud ~]# systemctl enable postfix
[root@monitoring-cloud ~]#
[root@monitoring-cloud ~]# systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2018-11-01 19:22:14 WIB; 30s ago
 Main PID: 119578 (master)
   CGroup: /system.slice/postfix.service
           ├─119578 /usr/libexec/postfix/master -w
           ├─119579 pickup -l -t unix -u
           ├─119580 qmgr -l -t unix -u
           ├─119581 trivial-rewrite -n rewrite -t unix -u
           ├─119582 smtp -t unix -u
           ├─119583 smtp -t unix -u
           ├─119584 smtp -t unix -u
           ├─119585 smtp -t unix -u
           ├─119586 smtp -t unix -u
           ├─119587 smtp -t unix -u
           ├─119588 smtp -t unix -u
           ├─119589 smtp -t unix -u
           ├─119590 bounce -z -n defer -t unix -u
           ├─119591 smtp -t unix -u
           ├─119592 bounce -z -n defer -t unix -u
           ├─119593 smtp -t unix -u
           ├─119594 smtp -t unix -u
           ├─119595 smtp -t unix -u
           ├─119596 smtp -t unix -u
           ├─119597 smtp -t unix -u
           ├─119598 error -n retry -t unix -u
           ├─119599 smtp -t unix -u
           ├─119600 error -n retry -t unix -u
           ├─119601 error -n retry -t unix -u
           ├─119602 error -n retry -t unix -u
           ├─119603 bounce -z -n defer -t unix -u
           ├─119604 error -n retry -t unix -u
           ├─119605 error -n retry -t unix -u
           ├─119606 bounce -z -n defer -t unix -u
           ├─119607 error -n retry -t unix -u
           ├─119608 bounce -z -n defer -t unix -u
           ├─119609 error -n retry -t unix -u
           ├─119610 error -n retry -t unix -u
           ├─119611 bounce -z -n defer -t unix -u
           ├─119612 error -n retry -t unix -u
           ├─119614 error -n retry -t unix -u
           ├─119616 error -n retry -t unix -u
           ├─119617 bounce -z -n defer -t unix -u
           ├─119628 cleanup -z -t unix -u
           ├─119629 local -t unix
           ├─119630 bounce -z -t unix -u
           ├─120142 bounce -z -n defer -t unix -u
           ├─120143 bounce -z -n defer -t unix -u
           ├─120144 error -n retry -t unix -u
           ├─120145 bounce -z -n defer -t unix -u
           ├─120146 error -n retry -t unix -u
           ├─120147 error -n retry -t unix -u
           ├─120148 bounce -z -n defer -t unix -u
           ├─120149 bounce -z -n defer -t unix -u
           ├─120150 error -n retry -t unix -u
           ├─120151 error -n retry -t unix -u
           ├─120152 bounce -z -n defer -t unix -u
           ├─120153 error -n retry -t unix -u
           ├─120154 bounce -z -n defer -t unix -u
           ├─120155 error -n retry -t unix -u
           ├─120156 bounce -z -n defer -t unix -u
           ├─120157 error -n retry -t unix -u
           ├─120158 bounce -z -n defer -t unix -u
           ├─120159 bounce -z -n defer -t unix -u
           ├─120160 error -n retry -t unix -u
           ├─120164 bounce -z -n defer -t unix -u
           ├─120165 bounce -z -n defer -t unix -u
           ├─120166 error -n retry -t unix -u
           ├─120167 error -n retry -t unix -u
           ├─120168 bounce -z -n defer -t unix -u
           ├─120169 error -n retry -t unix -u
           ├─120170 error -n retry -t unix -u
           ├─120171 bounce -z -n defer -t unix -u
           ├─120172 error -n retry -t unix -u
           ├─120173 bounce -z -n defer -t unix -u
           ├─120174 error -n retry -t unix -u
           ├─120175 bounce -z -n defer -t unix -u
           ├─120176 error -n retry -t unix -u
           ├─120177 bounce -z -n defer -t unix -u
           ├─120178 error -n retry -t unix -u
           ├─120179 bounce -z -n defer -t unix -u
           ├─120180 error -n retry -t unix -u
           └─120181 bounce -z -n defer -t unix -u

Nov 01 19:22:45 monitoring-cloud postfix/error[120178]: F0BAB10E64A6: to=<[email protected]>, relay=none, delay=378584, dela...able)
Nov 01 19:22:45 monitoring-cloud postfix/error[120172]: E718510E3ADB: to=<[email protected]>, relay=none, delay=101347, dela...able)
Nov 01 19:22:45 monitoring-cloud postfix/error[119612]: EF53810E5483: to=<[email protected]>, relay=none, delay=281738,...able)
Nov 01 19:22:45 monitoring-cloud postfix/error[119604]: EEA2010E3A56: to=<[email protected]>, relay=none, delay=101387, dela...able)
Nov 01 19:22:45 monitoring-cloud postfix/error[119601]: F27CE10E1529: to=<[email protected]>, relay=none, delay=105617, dela...able)
Nov 01 19:22:45 monitoring-cloud postfix/error[120174]: F3AE910E5539: to=<[email protected]>, relay=none, delay...able)
Nov 01 19:22:45 monitoring-cloud postfix/error[119614]: F1C0510E369D: to=<[email protected]>, relay=none, delay=71991, ...able)
Nov 01 19:22:45 monitoring-cloud postfix/error[120147]: F32C310E5147: to=<[email protected]>, relay=none, delay=287392, dela...able)
Nov 01 19:22:45 monitoring-cloud postfix/error[120167]: E0A5810E59A4: to=<[email protected]>, relay=none, delay=315472, dela...able)
Nov 01 19:22:45 monitoring-cloud postfix/error[119609]: F3FAE10E534E: to=<[email protected]>, relay=none, delay=281859,...able)
Nov 01 19:22:45 monitoring-cloud postfix/error[120170]: F054A10E3C35: to=<[email protected]>, relay=none, delay=101211, dela...able)
Nov 01 19:22:45 monitoring-cloud postfix/error[120166]: E63A810E653E: to=<[email protected]>, relay=none, delay=193757,...able)
Hint: Some lines were ellipsized, use -l to show in full.
[root@monitoring-cloud ~]#

Open the main.cf on postfix configuration directory
[root@monitoring-cloud ~]# vi /etc/postfix/main.cf

Write the following configuration on relayhost segment
myhostname = monitoring-cloud

relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous

Create a password file and write down the username and password on it 
[root@monitoring-cloud ~]# vi /etc/postfix/sasl_passwd
[root@monitoring-cloud ~]#


The example of the file content 
[root@monitoring-cloud ~]# cat /etc/postfix/sasl_passwd
[smtp.gmail.com]:587 [email protected]:Monitoring@567
[root@monitoring-cloud ~]#

Change the ownership of the file
[root@monitoring-cloud ~]# chown root:postfix /etc/postfix/sasl_passwd*
[root@monitoring-cloud ~]#


Testing the email by perform following command
[root@monitoring-cloud ~]# echo " this is a test mail." | mail -s "test message" [email protected]
[root@monitoring-cloud ~]#



Tidak ada komentar :

Posting Komentar