Daniels Blog
30Sep/220

Small SMS to Email gateway with Tasker, Android and a webserver

I wanted to forward SMS text messages to email. Tasker has an email action, but it won't automatically send the email, just provide the composing window.

Gladly Tasker can do HTTP-requests and read SMS, so we can forward the SMS to our own webserver to mail it from there.

 

Tasker part:

  • Create Profile "Incoming SMS"
  • Make it run Task "SMS2Email" when Event "Received Text SMS" is triggered.

 

  • Create new Task "SMS2Email"
  • In Task "SMS2Email:
  • Make sure mobile data is turned on
  • Do the following HTTP POST Action:

Server: https://www.myserver.com

Path: smsgateway.php

Data / File: sms=%SMSRF / %SMSRN / %SMSRB / %MMSRS / %SMSRD / %SMSRT

Trust any certificate: check

 

Webserver part on www.myserver.com:

# /var/www/smsgateway.php
<?php
$sms = $_POST["sms"];
$sms_parts = explode("/", $sms);

$sms_num = $sms_parts[0];
$sms_nam = $sms_parts[1];
$sms_txt = $sms_parts[2];
$sms_dat = $sms_parts[4];
$sms_tim = $sms_parts[5];

$body ="
$sms_dat $sms_tim
$sms_num
$sms_nam

$sms_txt
";

mail("targetemail@myserver.com", "SMS $sms_nam $sms_num", $body, "From: Snappy Sendername <smsservice@myserver.com>");
?>

Here we go. After receiving a SMS, Tasker makes the HTTP-request, delivering the content of the SMS to the webserver. PHP sends the content out by mail.

If you don't want to forward all SMS, you can add additional filters in Taskers event "Received Text SMS".

Make sure your PHP setup is able to deliver mail. Check if messages go to spam.

hat dir dieser Artikel gefallen?

Dann abonniere doch diesen Blog per RSS Feed!

veröffentlicht unter: Android, Linux Kommentar schreiben
Kommentare (0) Trackbacks (0)

Zu diesem Artikel wurden noch keine Kommentare geschrieben.


Leave a comment

Noch keine Trackbacks.