New Gmail in Inbox : Setup SMS Alerts for new Gmails in your Mailbox


Need? or Requirement?

Well, this setup is my requirement because I don’t have 24 hours running Internet on my mobile device. Neither it is possible to repeatedly check for new mails with really slow Internet. So, it became my requirement to receive SMS alert on new mails and check mails when I feel that something important has arrived.

Of course, most of tech-giants would not feel this useful for many and much more useful reasons. For every other fellow, I will try to make this setup look, lame.

Theory? / Concept? / Procedure?

Here comes the boring part. I request you not to read this theory part further because the setup is much more easy and you will understand the things as you go.

Still, for the sake of headline, lets take this challenge too.

This setup is basically described for Gmail users. We are going to setup something which will send a SMS notification on mobile device for every new email you receive on Gmail. We will now be using any third party here in our configuration. Instead we will use a google spreadsheet script and mobile verification in google calendar account. Doing this appropriately should solve our purpose for this post. Of course you can filter the the type of mails for which you want to receive SMS alerts, but that’s a later part. One more thing, and yes it is important one that the Messages sent to your phone will be…..


Note: Unless you mobile network carrier charge for it.

Starting the Setup:

The number of steps are large, but simple. It is because a complete step also asks to just do a single click.

1. Login to your Gmail account, if you don’t have one, then please create (at least for trying a dummy setup).

2. Click on the gear icon visible in rightmost corner of the account. You can also refer the screens attached below every step.


3. Click on “Settings” link from the dropdown.

4. Now, from the newly loaded page, click on “Labels” menu.


5. Scroll to the bottom of the page, click on “Create new label”.


6. Name it exactly “smsMail” and the click on “Create” button from the popup box. The popup should close now.


7. Now, from the same menu on which you clicked “Labels”, its time to click on “Filters”.


Now, we will filter the type of email notifications you want to receive. Like, you want to receive only those mails which contain name “Ankit Mathur”, such filtering can be done here. However, I would be highly obliged if you make a filter with my name and receive its notification in your mobile 😛

8. Again scroll down and reach bottom of the page.

9. Click on a link named as “Create a new filter”.


10. Now, from the new dropdown which has appeared you need to select the filter you want to make. Lets say, in the “To” textbox you fill your email id. Which will send notification for every that mail which is delivered on your email id.


11. After you have done with filter contents, click on “Create filter with this search >>” which is at the bottom of the dropdown window.

12. Now, the dropdown contents should get updated.

13. Checkmark the label saying “Apply the Label”.


14. Now, from the combo box in front of the label, select the label with exact name as “smsMail”.

15. Now, click on the blue button in the same dropdown which says “Create Filter”. The filter should be created by now.

———————————— End of settings in Mailbox ————————————

1. Now, go to google docs from the same logged-in account. If you can’t find the link, then follow here:

2. From the left-most menu, click on red colored “Create”, a dropdown will appear. Select “Spreadsheet” from it.


3. Now, from the spreadsheet menu, select “Tools” and go to “Script Editor”.


4. A new page with a popup will open up. From left menu, select “Spreadsheet”.


5. You will be redirected to a new page for writing some code. Don’t worry, I will provide you the code for it 🙂

6. In the code tab named as “”, select the prewritten code and brutally delete it. Blank the whole window and color it from the white blood of codes.

7. For the code, you can copy it from this link too: Github Link for the Code.

Also you can paste the below code in the same window
(but copying this below code may conflict some single quote issues. Better if you copy the code from above gist link):

function smsMail()
var label = GmailApp.getUserLabelByName(‘smsMail’);
var threads = label.getThreads();
var now = new Date().getTime();
var cal=getCalendar();for(i in threads)
{cal.createEvent(threads[i].getFirstMessageSubject()+”: “+threads[i].getMessages()[0].getFrom(),new Date(now+60000),
new Date(now+60000)).removeAllReminders().addSmsReminder(0);}
Logger.log(“Error Occured”+ err.toString());
}function getCalendar()

var cal=CalendarApp.getOwnedCalendarsByName(“smsMail”)[0];

if (!cal)
return cal;

return cal;
Logger.log(“Error Occured”+ e.toString());


function onOpen()
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [ {name: “Authorize”, functionName: “authorize”},
{name: “Stop SMS alerts”, functionName: “stopsmsalerts”}
ss.addMenu(“Gmail SMS Alerts”, menuEntries);

function authorize(){}

function stopsmsalerts()
var allTriggers = ScriptApp.getScriptTriggers();

for(var i=0; i < allTriggers.length; i++)

Browser.msgBox(“Success”, “You will not be getting SMS alerts anymore.”,Browser.Buttons.OK);

8. Now, from the window menu, click on “File” and save the file with name exactly “smsMail”.


9. Now, from the same window menu, click on “Run” and from the dropdown select “authorize”.

10. Now, close this window and go to the spreadsheet. Close the spreadsheet and reopen it. You will be able to see a new menu as “Get SMS Alerts”.


11. Click on it and from the dropdown select “Authorize”.

12. Close the spreadsheet too.

————- Here we are done with the spreadsheet configuration ————

1. Go to google calendar from the same logged-in account.

2. From the rightmost gear icon, click on “Settings”.


3. Now, depends on you whether you want calendar alerts on all of the checks available or only on mobile. So, select wisely.


For now, lets select “SMS” only. If your mobile is not connected to google calendar then, it is necessary for you to connect it because without it you won’t receive SMS on your mobile device.

To connect your mobile device with calendar, enter your mobile number in the corresponding textbox for “SMS”. Then click the corresponding button to it. Google will send you a code which you will need to enter in the same textbox in which you entered your mobile number (Notice that the textbox has gone blank by now). Again click on the corresponding button to confirm.

By now, you should be done with the mobile number connection.

NOTE: This is the most important step because if the mobile number doesn’t get configured in calendar then you won’t receive SMS anyhow from the script.

Moving to next step, please let me know if you can’t configure the mobile number here. We will try it again, together.

4. Now from the same gearbox in the right corner, go to “Settings”.


5. You will be shown “General” tab. Please recheck your country details, timezone details and other details. Make sure they are correct for your location.

6. Now, from the tabs menu, go to “Calendars” tab.


7. Here, you should see “smsMail” in your calendar list. Check mark in front of it, save and then and click on “Reminders and Notifications”.

8. Now, check mark all the types of notifications you wish to receive as SMS.


9. Now, save and return to calendar settings screen.

10. Now, move to “Mobile Setup” tab and make sure your mobile number is shown verified there. Else, verify it there.


11. Now, you need to reopen the same spreadsheet which you used to copy-paste the script.  Under tools menu, select “Script Editor”.

12. Now, in the script window’s menu click on “Resources” and select “Current project’s triggers”. Add a new trigger here according to the frequency you wish to receive the mails.



13. You are done with the setup here. Send a test mail to yourself and a message about same should beep on your mobile device. Else, let’s discuss here. We together will try to solve the issue, chill! 🙂




32 responses to “New Gmail in Inbox : Setup SMS Alerts for new Gmails in your Mailbox

  1. I nearly completed setup as you described.
    I had to debug the shape of some of the double quotation marks to make your code run 😀 The phone sync and verification went well.
    At point 6 though, I didn’t get the smsMail calendar to appear in my calendar list so sending an email to myself does not result in receiving an SMS at the moment. Thanks for putting this post up.
    Any suggestions?

    • Hi Tom!
      Thanks for stepping up with queries.
      Well, as your next reply says that you have managed to get “smsMail” in calendar list, then its well and good. Still, for future reference I would say that those who are not getting the name i.e. “smsMail” in calendar list, they can create a new calendar with name “smsMail” and set your timezone in that calendar’s settings.

      Good Luck! 🙂

  2. OK, I have the smsMail calendar appearing now. I’m not a coder and made a mistake correcting the first error which was returned at line 5 when I tried to run it. Getting the right shaped single quotation marks around ‘smsMail’ was the problem.
    Still not working yet though. I’ll keep going with it.

    • Haha!

      No problem dude if you are not that good with codes. I have created a link from which you can copy the same code and paste it in your code window. Here is the link:
      I have also added the same link in above description too.

      One more step is missing in this setup described above. After a couple of hours, I’ll be adding it in the process, that will complete the setup.
      This new step will be added in the end (i.e. 12th step) of the description so that you can easily get which is new step in the process.

      Please let me know if you face any issues further.

      Kind regards,
      Ankit 🙂

  3. Ankit
    Thank you for your reply.
    Adding the smsMail project trigger resulted in my receiving an SMS notification to my phone 😎
    It arrived on my phone 9 minutes after the email was received.
    Two minutes later I received the same SMS notification again.
    Not sure why that happened.

    • Glad to know that this worked for you too 🙂
      Well, I think yesterday when you tried to check if you get SMS on new mail, it failed. But today when you again tried with same subject of eMail ,then you got both notifications i.e. one of today’s and the other of yesterday’s. Both being with same subjects (quite possibly).

  4. Thank you Ankit for your sharing.
    Everything is working fine now.

  5. Interesting is that I got the SMS twice. First one 10 minutes after the email arrived and the second one 15 minutes after the email arrived. Why twice?

  6. i think everything went fine. first the smsmail didnt display on my calendar so i created it myself. finally got the msgs for the mails. in the event trigger, i kept minutely reminder and im continuously getting a remainder drom smsmail. any help on this?

    • Its probably because of the already existing and unread mails in your inbox. Nothing to worry about, once these will stop, then new messages will start following on arrival of new and unread mail.

      • i haven’t been getting msgs today, so i had a look at my calendar. it shows around some 10-15 reminders in a span of 5-10 minutes. so why are those reminders in my calendar?
        even the promotions tab has been excluded from my smsmail too.

        • Removal of promotions tab isn’t effect of this functionality. You can regain the tab from Gmail settings, let me know if I can help you in restoring the tab.

          Apart from this, let the script run once completely, either the message frequency set by you is conflicting somewhere or you still have some unread mails in the inbox.

  7. Hello Ankit Mathur . Really it worked fine for me . Thanks a ton .

    Is there any way to get the message in the mail instead of getting alerts.

    Thanks in advance . waiting for the rely

  8. I just stopped with this step,
    10. Now, close this window and go to the spreadsheet. Close the spreadsheet and reopen it. You will be able to see a new menu as “Get SMS Alerts”.

    I can’t get this new menu “Get SMS Alerts”. What can I do ?

    • The new menu gets created automatically with the script. You can recheck the code or create a new sheet with same process after deleting this one.

    • Hi Rohan,
      It would be only you who can figure out the issue if there is any. Please try to work out with codes again.

      At least mention, what you aren’t able to catch-up with…..
      I hope, you can repeat the procedure and set it up easily as others have done 🙂
      All the best.

Comments are closed.