postfix to gmail with multiple user configuration

http://www.zoneminder.com/wiki/index.php/How_to_install_and_configure_Postfix_as_a_Gmail_SMTP_relay_for_ZoneMinder_email_filter_events.

http://www.ulduzsoft.com/2012/02/your-personal-gmail-like-mail-system-smtp-server/

vim /etc/postfix/mail.cf

#add this line

relayhost = [smtp.gmail.com]

smtp_sasl_auth_enable = yes

smtp_sasl_password_maps = hash:/etc/postfix/sasl_password

smtp_sasl_security_options = noanonymous

smtp_use_tls = yes

smtp_sasl_tls_security_options = noanonymous

smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt

vim /etc/postfix/sasl_password

smtp.gmail.com  xyz333999@gmail.com:password@123

postmap  /etc/postfix/sasl_password

/etc/init.d/postfix restart

check it

echo redhat | mail -s test xyz333999@gmail.com

and its log look like as

Nov 22 13:23:30 desktop11 postfix/pickup[17825]: 61D21664E0: uid=0 from=<root>

Nov 22 13:23:30 desktop11 postfix/cleanup[18077]: 61D21664E0: message-id=<20121122075330.61D21664E0@desktop11.example.com>

Nov 22 13:23:30 desktop11 postfix/qmgr[17826]: 61D21664E0: from=<root@desktop11.example.com>, size=453, nrcpt=1 (queue active)

Nov 22 13:23:30 desktop11 postfix/smtp[18080]: connect to smtp.gmail.com[2607:f8b0:400e:c01::6d]:25: Network is unreachable

Nov 22 13:23:35 desktop11 postfix/smtp[18080]: 61D21664E0: to=<bipinpatel333999@gmail.com>, relay=smtp.gmail.com[173.194.79.108]:25, delay=5.3, delays=0.1/0.05/2.9/2.3, dsn=2.0.0, status=sent (250 2.0.0 OK 1353570815 rk17sm1660101pbb.3)

Nov 22 13:23:35 desktop11 postfix/qmgr[17826]: 61D21664E0: removed

now see mail  in your gmail account

multiple user configuration

now we see multiple user with postfix

add the line in postfix main.cf file

vim /etc/postfix/mail.cf

# Disable sending mail without authentication, and allow any destination if authenticated
smtpd_client_restrictions = permit_sasl_authenticated, reject_unauth_destination, reject
smtpd_sender_restrictions = permit_sasl_authenticated
smtpd_recipient_restrictions = permit_sasl_authenticated,reject_unauth_destination

# Use different mail relays for the different logins
smtp_sender_dependent_authentication = yes
sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay

[root@desktop11 postfix]# cat sasl_passwd

root@desktop11.example.com    xyz333999@gmail.com:123456

student@desktop11.example.com    abc@gmail.com:123456

[root@desktop11 postfix]# postmap sasl_passwd

[root@desktop11 postfix]# cat sender_relay

root@desktop11.example.com    smtp.gmail.com:587

student@desktop11.example.com    smtp.gmail.com:587

[root@desktop11 postfix]# postmap sender_relay

[root@desktop11 postfix]# /etc/init.d/postfix restart

Shutting down postfix:                                     [  OK  ]

Starting postfix:                                          [  OK  ]

[root@desktop11 postfix]# echo redhat | mail -s test test@gmail.com

[student@desktop11 ~]$ echo from student user | mail -s student user test333@gmail.com

Advertisements

About bpn4it

Feel Free in Linux. Bipin Patel bpn4it@gmail.com Ahmadabad, Gujarat, India
This entry was posted in Bipin hands-on. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s