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


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 "U:root" "" "P:PASSWORD" AuthInfo: "U:root" "" "P:PASSWORD"

Save & Exit & issue below command

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

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 #
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl
define(`confAUTH_OPTIONS', `A p')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 .

– – – – -??

Syed Jahanzaib


  1. you are good!!

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



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

  2. Great !!!!!!

    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.

    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.

      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?

    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?

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

    • I would also like to know

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

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

      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,

    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.

      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.

        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.

        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,

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

  8. i have a problem, mt ip = squid ip =
    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 ( Invalid Request
    lientTryParseRequest: FD 300 ( Invalid Request
    plzzz resolve this issue or guide me to resolve this.thxzzzzzzzzzz

    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

    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 after taking some time.
    some error may help u in cache.log
    2013/04/22 00:42:05| clientTryParseRequest: FD 104 ( Invalid Request
    2013/04/22 00:42:35| clientTryParseRequest: FD 157 ( Invalid Request
    2013/04/22 00:44:08| clientTryParseRequest: FD 348 ( Invalid Request
    2013/04/22 00:44:16| clientTryParseRequest: FD 278 ( Invalid Request
    2013/04/22 00:45:51| squidaio_queue_request: WARNING – Queue congestion
    2013/04/22 00:46:56| clientTryParseRequest: FD 40 ( Invalid Request
    2013/04/22 00:47:05| clientTryParseRequest: FD 328 ( Invalid Request

    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.

    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 !!!

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

  13. DearBro

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

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

  14. How are you my friends Syed, help me please. email 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 []
    Apr 3 15:34:50 debian sm-mta[11351]: t33JY7JE011348: to=, delay=00:00:43, xdelay=00:00:43, mailer=relay, pri=120436, [], dsn=4.0.0, stat=Deferred: Connection timed out with
    Apr 3 15:40:34 debian sm-mta[11483]: t33JY7JE011348: to=, delay=00:06:27, xdelay=00:00:42, mailer=relay, pri=210436, [], dsn=4.0.0, stat=Deferred: Connection timed out with

    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

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

RSS feed for comments on this post. TrackBack URI

Leave a Reply

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

You are commenting using your 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

Blog at

%d bloggers like this: