Syed Jahanzaib – Personal Blog to Share Knowledge !

December 27, 2012

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

Filed under: Linux Related, Radius Manager — Tags: , , — Syed Jahanzaib / Pinochio~:) @ 3:01 PM

gmail-logo

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. that’s why I wrote this guide, it maybe useful for others too . . Syed Jahanzaib }

OS Used: Ubuntu 10.4 / 12.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 questions , 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 code box.
nano  /etc/mail/authinfo
AuthInfo:smtp.gmail.com "U:root" "I:USERNAME@gmail.com" "P:PASSWORD" AuthInfo: "U:root" "I:USERNAME@gmail.com" "P:PASSWORD"

Save & Exit & issue below command

makemap hash /etc/mail/authinfo < /etc/mail/authinfo
Now Add the following configurations at the bottom of sendmail.mc file
nano /etc/mail/sendmail.mc

dnl #
dnl # SSL Settings
define(`CERT_DIR', `MAIL_SETTINGS_DIR`'certs')
define(`confCACERT_PATH', `CERT_DIR')
define(`confCACERT', `CERT_DIR/CAcert.pem')
define(`confSERVER_CERT', `CERT_DIR/mycert.pem')
define(`confSERVER_KEY', `CERT_DIR/mykey.pem')
define(`confCLIENT_CERT', `CERT_DIR/mycert.pem')
define(`confCLIENT_KEY', `CERT_DIR/mykey.pem')
dnl #
dnl # GMAIL FORWARDING
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_OPTIONS', `A p')dnl
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
FEATURE(`authinfo',`hash -o /etc/mail/authinfo.db')dnl

Now rebuild sendmail config and start the service 😀

make -C /etc/mail
service sendmail restart

 

Test the setup 😉

Use the below command to test the local smtp .

– – – – -??

Regard’s
Syed Jahanzaib

34 Comments »

  1. you are good!!

    please make a new folder “Raidus Manager” how ever every one can found ur RM configs easily.

    regards,

    Nomi

    Like

    Comment by Nomi — December 28, 2012 @ 9:30 PM

  2. Great !!!!!!

    Like

    Comment by faizan — December 29, 2012 @ 12:37 PM

  3. Hi
    Great work as usual
    How can I enter my Email credentials (not Gmail) in Sendmail using Webmin?
    Thank you.
    David

    Like

    Comment by David — January 22, 2013 @ 8:15 PM

    • I have no idea as I have never configured SENDMAIL via webmin, Also its not recommended. Because most of the options in sendmail should be configured via CLI.

      Like

      Comment by Syed Jahanzaib / Pinochio~:) — January 23, 2013 @ 11:05 AM

  4. can i use this setup to send from my mail servrr if i use my details?

    Like

    Comment by Harley — March 10, 2013 @ 3:05 PM

  5. Hi there Syed,
    How do i go about changing the sender header from admin@localhost to something more relevant?

    Like

    Comment by Harley — March 14, 2013 @ 3:19 AM

    • I would also like to know

      Like

      Comment by Juan Kilian — April 9, 2013 @ 2:11 PM

    • I found it – inside system_cfg.php change sender address and restart rmpoller

      Like

      Comment by Juan Kilian — April 15, 2013 @ 11:49 AM

  6. Salam to all,
    dear janzaib i need QOS script for squid bcoz squid consume full bandwidth when it completing any request, so plzzz if u have a time then publish any gud script for QOS in squid or with squid,
    thanking you,

    Like

    Comment by rehmat ali — April 16, 2013 @ 7:01 PM

    • The better way to restrict squid to use certain fix amount of bandwidth, route all traffic from squid to mikrotik, and create queue for squid ip that can restrict bandwidth.

      Like

      Comment by Syed Jahanzaib / Pinochio~:) — April 17, 2013 @ 8:09 AM

      • i googled and find some, delay_pool class parameters
        is it can limit the squid to use mentioned bandwidth if yes then i try that squid cant recognize delay_etc, how lusca/squid able to recognize delay_pool etc, plzz mention.

        Like

        Comment by rehmat ali — April 18, 2013 @ 2:24 AM

      • Yes delay pool can help you. but its management will be a overhead for you as you have to reserve ip for each user in your pppoe/hotspot profile, so you can create different ip base groups, and based on these ip groups, you can apply different delay bandwidth restrictions.

        Like

        Comment by Syed Jahanzaib / Pinochio~:) — April 18, 2013 @ 8:08 AM

  7. yes u r right i tried delay_pool methods but i fail to accomplished after that i tried simple queue method and its done thxzzz 4 ur guide man,
    keep it up,

    Like

    Comment by rehmat ali — April 19, 2013 @ 9:14 AM

  8. i have a problem, mt ip = 192.168.9.2 squid ip =192.168.9.1
    all tcp 80 traffic passthrough from mt to squid and i m receving zero sized reply on browser.
    in cache.log i seen this…..
    squidaio_queue_request: WARNING – Queue congestion
    lientTryParseRequest: FD 128 (192.168.9.2:4105) Invalid Request
    lientTryParseRequest: FD 300 (192.168.9.2:26672) Invalid Request
    plzzz resolve this issue or guide me to resolve this.thxzzzzzzzzzz

    Like

    Comment by rehmat ali — April 21, 2013 @ 8:03 PM

  9. clientEatRequestBodyHandler: FD 51: no more data left in socket; but request header says there should be; aborting for now

    Like

    Comment by rehmat ali — April 22, 2013 @ 1:13 AM

  10. i did not route all traffic from squid to mikrotik to restrict squid to consume full bandwidth i had just replaced squid wan port from ptcl router to mt lan port and make a firewall rule of src-nat in mt and masqurate all traffic src squid wan ip. also make a simple interface queue to limit squid bandwidth.
    i think after this all my squid making a problem its stuck on facebook and zero sized reply on bbc.co.uk after taking some time.
    some error may help u in cache.log
    2013/04/22 00:42:05| clientTryParseRequest: FD 104 (192.168.9.2:3299) Invalid Request
    2013/04/22 00:42:35| clientTryParseRequest: FD 157 (192.168.9.2:17231) Invalid Request
    2013/04/22 00:44:08| clientTryParseRequest: FD 348 (192.168.9.2:4714) Invalid Request
    2013/04/22 00:44:16| clientTryParseRequest: FD 278 (192.168.9.2:17309) Invalid Request
    2013/04/22 00:45:51| squidaio_queue_request: WARNING – Queue congestion
    2013/04/22 00:46:56| clientTryParseRequest: FD 40 (192.168.9.2:1430) Invalid Request
    2013/04/22 00:47:05| clientTryParseRequest: FD 328 (192.168.9.2:3619) Invalid Request

    Like

    Comment by rehmat ali — April 22, 2013 @ 1:33 AM

  11. Non Payment Reminder for Expired Users in RADIUS MANAGER 4.x.x:

    follow all your instructions, but does not work.

    Juan Carlos.
    jcgutierrezo@gmail.com

    Like

    Comment by Juan Carlos — December 23, 2014 @ 8:43 AM

  12. hi can you help, we were unable to login to radius today so did a reboot and can’t get it back !!!

    Like

    Comment by Liz — January 16, 2015 @ 11:39 PM

  13. DearBro

    kindly suggest suitable script for IAS for radius manager, for client end.

    Like

    Comment by Raj — January 31, 2015 @ 7:15 PM

  14. How are you my friends Syed, help me please. email :jramirez@csrconsultores.com regards-

    3 15:34:07 debian sm-mta[11348]: t33JY7JE011348: from=, size=436, class=0, nrcpts=1, msgid=, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
    Apr 3 15:34:50 debian sm-mta[11351]: t33JY7JE011348: to=, delay=00:00:43, xdelay=00:00:43, mailer=relay, pri=120436, relay=gmail-smtp-msa.l.google.com. [74.125.137.109], dsn=4.0.0, stat=Deferred: Connection timed out with gmail-smtp-msa.l.google.com.
    Apr 3 15:40:34 debian sm-mta[11483]: t33JY7JE011348: to=, delay=00:06:27, xdelay=00:00:42, mailer=relay, pri=210436, relay=gmail-smtp-msa.l.google.com. [74.125.137.109], dsn=4.0.0, stat=Deferred: Connection timed out with gmail-smtp-msa.l.google.com.

    Like

    Comment by Jose Ramirez — April 4, 2015 @ 12:43 AM

  15. can u tell me how to configure DMASOFTLAB RM 4.0.4 Email Notifications in Debian 7.5 32 bit please

    Like

    Comment by shanto — May 21, 2015 @ 2:43 PM

  16. I am using CentOS. Please update

    Like

    Comment by Md Ikhtiaruddin — July 22, 2017 @ 6:17 AM

  17. Can you pls update this solution to work for RM Version 4.1.6 please..

    Like

    Comment by James Anthony — March 1, 2019 @ 1:28 PM

    • This can work DMA RM 4.x series , infacet its just a email relay server, so you can use it with any application regardless of operating system architecture.

      Like

      Comment by Syed Jahanzaib / Pinochio~:) — March 3, 2019 @ 11:03 AM

  18. hello sir
    i have face one error——————————— ( Email address banned! )
    Telme what is this problem

    Like

    Comment by Mian Bilal Dolla — August 3, 2019 @ 9:50 PM


RSS feed for comments on this post. TrackBack URI

Leave a comment