Showing posts with label SMTP. Show all posts
Showing posts with label SMTP. Show all posts

Thursday, July 12, 2012

Configuring sendmail to relay mail through Gmail SMTP

1.                  Create User Account on Gmail.com.

2.                  Check network setting for lookup/telnet of smtp.gmail.com.

3.                  Create local user for sending mail through Gmail account to other mail account.

4.                  Edit /etc/mail/sendmail.mc file and add below parameters.

define(`SMART_HOST', `smtp.gmail.com')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
FEATURE(`authinfo', `hash /etc/mail/auth/client-info')dnl
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl

5.                  Create “auth” folder.

# mkdir /etc/mail/auth

6.                  Create “client-info” file and add below paramters.

# vi /etc/mail/auth/client-info
AuthInfo:smtp.gmail.com "U:gmail_test_user" "I:gmail_test_user@gmail.com" "P:gmail_test_user_password"

7.                  Change folder location and create database.

# cd  /etc/mail/auth/
# makemap hash client-info < client-info

8.                  Change permission of file and folder.

# chmod 700 /etc/mail/auth
# chmod 600 /etc/mail/auth/*

9.                  Compile configuration & restart service.

# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
# service sendmail restart

10.              Finally, send a test mail.

# echo 'this is a test mail'| mail -s welcome_to_testmail second_test_user@hotmail.com

11.              Check log message.

# tail -f /var/log/maillog
# tail –f /var/log/messages