Skip to content

Instantly share code, notes, and snippets.

@quangbahoa
Forked from duttajit50/sendsms
Last active August 29, 2015 14:20
Show Gist options
  • Save quangbahoa/d9ce90b54f8ca7e6d04e to your computer and use it in GitHub Desktop.
Save quangbahoa/d9ce90b54f8ca7e6d04e to your computer and use it in GitHub Desktop.
Send Google SMS
function sendsms()
{
try
{
var label = GmailApp.getUserLabelByName('sendsms');
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);
}
label.removeFromThreads(threads);
}
catch(err)
{
Logger.log("Error Occured"+ err.toString());
}
}
function getCalendar()
{
try
{
var cal=CalendarApp.getOwnedCalendarsByName("sendsms")[0];
if (!cal)
{
cal=CalendarApp.createCalendar("sendsms");
return cal;
}
else
{
return cal;
}
}
catch(e)
{
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++)
ScriptApp.deleteTrigger(allTriggers[i]);
Browser.msgBox("Success", "You will not be getting SMS alerts anymore.",Browser.Buttons.OK);
}

Get Gmail Notification Sms Free – How to

With the help of some third-party services or using sms gateway in email forward option one can get ‘gmail sms alerts’ but of course these services are not free and there might be some privacy related issues. However you will get instant answers to these queries regarding a just-received email.

Subject of the email. Name and email address of the sender. Exact time with date for each new individual unread email. Getting started with ‘Free Gmail mobile alert system’, you just need to cover few simple steps as mention below.

Step I: Make Free Sms Reminder with Google Calendar Set-up

Sign in to Google Calender.

From top-right corner of your browser Click on Gear button and select Settings.

gear-icon-gmail

Go to Mobile Setup tab and verify your mobile number there.

google-calendar-phone-verification

You will automatically be redirected to Reminders and Notifications page.

Set Sms option as your default event reminder and set the time to 3 minutes.

set-event-reminder

Now click on save button to complete Google calendar configuration for phone notification.

Step II: Configure Gmail and Create Filter

Sign in to your Gmail account and from the icon select settings.

Go to labels tag, create a new label with the name sendsms.

Now create a new filter from Filters tab and to get sms alerts for all new emails from Gmail inbox.

Enter “is:inbox” in the ‘Has the words’ field.

To bypass email alerts for social and promotional emails enter “category:social,category:promotions” in “Doesn’t have” field.

See the picture below:

create-filter-gmail

Select “Create Picture with this Search” option.

Tick the box “Apply the label” > then select “sendsms” > click “Create filter”.

Step III: Configure Google Spreadsheet and add some actionscript

Sign in to Google spreadsheet.

Create a new spreadsheet.

Navigate to Tools and choose Script Editor.

script-editor-for-free-sms

Get the code from this link and paste it in script editor page.

Select Resources > Current project’s triggers.

google-script-for-free-sms alert

Click on “Add a new trigger” and configure the trigger as per the below image.

set-trigger-for-free-sms-gmail

At the Run field select ‘sendsms‘.

At the Events field select Time Driven >> Minutes Timer >> Every Minute. Then click Save button.

To authorize the script, click on continue and Save respectively.

Now click on Save icon from the top menu and close the Window.

save-google-scripts

Now back to Google spreadsheet and you will find ‘Gmail Sms Alerts’ tab there.

Select ‘Authorize’.

gmail-sms-alerts

Click on Ok.

Finally when you will be asked for Gmail integration permission, Accept it.

That’s it. Now you’ll instantly get an sms alert as soon as any email will come to your Gmail Inbox.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment