Saturday 19 January 2013

Howto configure GMAIL as SENDMAIL RELAY :D (Also can be used with RM to send Email Notifications)

Post : Howto configure GMAIL as SENDMAIL RELAY :D (Also can be used with RM to send Email Notifications)
URL : http://aacable.wordpress.com/2012/12/27/howto-configure-gmail-as-sendmail-relay-d-also-can-be-used-with-rm-to-send-email-notifications/
Posted : December 27, 2012 at 3:01 PM
Author : Syed Jahanzaib / Pinochio~:)
Categories : Linux Related
http://aacable.files.wordpress.com/2012/12/gmail-logo.jpg&h=224
If you want to use GMAIL as your sendmail relay server, Use the below configuration.
{I required it to send DMASOFTLAB RADIUS MANAGER Email notifications to all users regarding there service status, account expiry, renewal , various alerts and other info. thats why I wrote this guide, it maybe useful for others too . . Syed Jahanzaib }
OS Used: Ubuntu 10.4
First install Sendmail and its utilities.
apt-get install sendmail mailutils
Now configure signed SSL certificates
mkdir /etc/mail/certs
chmod 700 /etc/mail/certs
cd /etc/mail/certs
openssl dsaparam 1024 -out dsa1024 -out dsa1024.pem
(It will ask you various questiosn , just enter them accordingly, like country code, for Pakistan its PK, and other information you have)
openssl req -x509 -nodes -days 3650 -newkey dsa:dsa1024.pem -out /etc/mail/certs/mycert.pem -keyout /etc/mail/certs/mykey.pem
(It will ask you various questiosn , just enter them accordingly, like country code, for Pakistan its PK, and other information you have)
openssl req -x509 -new -days 3650 -key /etc/mail/certs/mykey.pem -out /etc/mail/certs/mycert.pem
ln -s /etc/mail/certs/mycert.pem /etc/mail/certs/CAcert.pem
chmod 600 /etc/mail/certs/*
cd ..
Now configure gmail SMTP authentication information, This file may be blank, just paste the text showed in green text.
nano  /etc/mail/authinfo
<span style="color: #008000;">AuthInfo:smtp.gmail.com "U:root" "I:USERNAME@gmail.com" "P:PASSWORD"</span>
<span style="color: #008000;">AuthInfo: "U:root" "I:USERNAME@gmail.com" "P:PASSWORD"</span>
<span style="color: #008000;">makemap hash -o /etc/mail/authinfo < /etc/mail/authinfo</span>
Now Add the following configurations at the bottom of sendmail.mc file
nano /etc/mail/sendmail.mc
<span style="color: #008000;">dnl #</span>
<span style="color: #008000;">dnl # SSL Settings</span>
<span style="color: #008000;">define(`CERT_DIR', `MAIL_SETTINGS_DIR`'certs')</span>
<span style="color: #008000;">define(`confCACERT_PATH', `CERT_DIR')</span>
<span style="color: #008000;">define(`confCACERT', `CERT_DIR/CAcert.pem')</span>
<span style="color: #008000;">define(`confSERVER_CERT', `CERT_DIR/mycert.pem')</span>
<span style="color: #008000;">define(`confSERVER_KEY', `CERT_DIR/mykey.pem')</span>
<span style="color: #008000;">define(`confCLIENT_CERT', `CERT_DIR/mycert.pem')</span>
<span style="color: #008000;">define(`confCLIENT_KEY', `CERT_DIR/mykey.pem')</span>
<span style="color: #008000;">dnl #</span>
<span style="color: #008000;">dnl # GMAIL FORWARDING</span>
<span style="color: #008000;">define(`SMART_HOST',`[smtp.gmail.com]')dnl</span>
<span style="color: #008000;">define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl</span>
<span style="color: #008000;">define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl</span>
<span style="color: #008000;">define(`confAUTH_OPTIONS', `A p')dnl</span>
<span style="color: #008000;">TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl</span>
<span style="color: #008000;">define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl</span>
<span style="color: #008000;">FEATURE(`authinfo',`hash -o /etc/mail/authinfo.db')dnl</span>
Now rebuild sendmail config and start the service :D
make -C /etc/mail
service sendmail restart
Test the setup ;)  The Result :~)




















No comments:

Post a Comment