Jump to content
Fi8sVrs

SMTP to SMS gateway

Recommended Posts

  • Active Members
Posted

Description

This is a very simple way to build yourself a small scale SMTP to SMS gateway, to allow you to send emails to your mobile phone.

Requirements

  • Old mobile phone with a pre-paid phone card, so you won't end up with a nasty bill.

http://www.e-things.org/smtp2sms/images/mobile_phone.png

  • Data cable

http://www.e-things.org/smtp2sms/images/phone_cable.png

  • Phone charger

http://www.e-things.org/smtp2sms/images/phone_charger.png

  • Linux PC (Pentium 120Mhz with 32MB RAM)

http://www.e-things.org/smtp2sms/images/pc_486.png

Installation

Connect your phone to COM1 (/dev/ttyS0) using your data cable.

Download and install Gnokii.

su -

rpm -ivh ftp://ftp.gnokii.org/pub/gnokii/binaries/RedHat/gnokii-0.4.3-1.i386.rpm

rpm -ql gnokii # List files

more /usr/share/doc/gnokii-0.4.3/COPYING

more /usr/share/doc/gnokii-0.4.3/CREDITS

more /usr/share/doc/gnokii-0.4.3/README

cp /usr/share/doc/gnokii-0.4.3/gnokiirc ~/.gnokiirc

vi ~/.gnokiirc

# set "model = " to suite your phone
# set "connection = " to suite your cable

# in my case I set
# "model = 7110"
# "connection = dau9p"
# and had to comment out "require_dcd = 1"


# Now test that gnokii can find your phone

gnokii --monitor

# send yourself an SMS

echo "Test SMS message" | gnokii --sendsms [your mobile number]

Example POP3 to SMS Perl script

#!/usr/bin/perl

use Net::POP3;

my $mail_server="mailserver";
my $username="username";
my $password="password";
my $phoneNumber="phonenumber";
my $gnokii = "|/usr/bin/gnokii --sendsms $phoneNumber";


my $pop = Net::POP3->new($mail_server)
or die "Can't open connection to $mail_server : $!\n";

defined ($pop->login($username, $password))
or die "Can't authenticate: $!\n";

$messages = $pop->list
or die "Can't get list of undeleted messages: $!\n";

foreach my $msgid (keys %$messages) {
my $email = $pop->get($msgid);
unless (defined $email) {
warn "Couldn't fetch $msgid from server: $!\n";
next;
}

my $header=1;
my $message = "";

# $message is a reference to an array of lines
foreach (@$email) {

if ($_ =~ /^\n/ && $header == 1) {
$header = 0;
}

if ($header == 1 &&; /^From:\s/) {
my ($from) = ($_ =~ /([\w\d\.-_]+@[\w\d\.-]+)/);
$from =~ s/[\<\>]//g;
$message .= "Frm $from\n";
}

if ($header == 1 && /^Subject:\s/) {
my ($subject) = ($_ =~ s/^Subject:/Sbj/g);
$message .= "$_";
}

if ($header == 0) {
s/are/R/gi;
s/you/U/gi;
s/before/B4/gi;
s/see\syou/CU/gi;
# etc, etc.
$message .= "$_";
}
}

# limit to SMS 160 char limit.
$message = substr($message, 0, 160);

# send this message
open(GNOKII, $gnokii) or die "$0: Could not open $gnokii\n";
print GNOKII $message;
close GNOKII;

# mark message to be deleted at quit below
$pop->delete($msgid);
}

$pop->quit($mail_server);

exit 0;

scr

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...