Linux Tip: Configuring Sendmail to use Gmail as an SMTP Server

[Update 03102010]

My linux server recently suffered a hardware failure and had to be rebuilt.   I had to setup this up again and rain into issues.   I found another article which is much more straightforward.


Wireless networking is pretty much common place these days. I've been using it at home for a number of years now and have been using security from day 1. Today I noticed that my Linksys router forgot my Wireless Security settings, leaving me exposed. I have no idea how long i've been open so needless to say i'm not pleased.

I have a script which polls my router and if my ip address has changed, it updates my dynamic dns account. So I thought it should be pretty easy to write a script to check my wireless security settings.

The script was pretty simple:


cd /scripts

wget --http-user=admin \
  --http-passwd=admin --no-check-certificate
success=`grep "\"wpa_personal\" selected" WL_WPATable.asp | wc -l`

if [ $success -ne 1 ]; then
Please check wireless security settings.  There seems to be a problem.

rm WL_WPATable.asp

Note: Notice the rm command at the end of the script. You need to do this if your using wget because if it detects the page your trying to download already exists it appends a version number to the end. ie. WL_WPATable.asp.1 If this happens, your script won't be checking the right file.

Pretty simple script, the only problem is, I didn't receive an email. My linux server is on my home network, which doesn't have an smtp server and I believe they are blocked by my ISP anyways.

I found a webpage which describes how to configure sendmail to use gmails smtp server.

A correction and addition. He mentions to "Create or edit the /etc/authinfo file and with this codes". However if you cut and paste his instructions the path placed in for this file is

FEATURE(`authinfo’, `Hash -o /etc/mail/authinfo’)dnl

So make sure you create authinfo in the same location. Towards the end he mentions to execute the make command. If you don't have the sendmail source this will not work for you. So instead of:

make all install restart


[root@stockade mail]# m4 >
[root@stockade mail]# /etc/init.d/sendmail restart

Note: Any email now sent from your server will be from your gmail account. I've sent the emails to my phone and gmail account, so if my wireless security gets disabled again i'll know right away.

Anyways, thought it may be useful.

1 comment:

Sridevi Koduru said...

Sridevi Koduru (Senior Oracle Apps Trainer
LinkedIn profile -
Please Contact for One to One Online Training on Oracle Apps Technical, Financials, SCM, Oracle Manufacturing, OAF, ADF, SQL, PL/SQL, D2K at | +91 - 9581017828.