<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Guru dell&#039;Eccelso Picco &#187; mail2sms sms mail gateway postfix procmail foxbox</title>
	<atom:link href="http://blog.gurudelleccelsopicco.org/tag/mail2sms-sms-mail-gateway-postfix-procmail-foxbox/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.gurudelleccelsopicco.org</link>
	<description>Things should be as simple as possible, but not simpler. 		-- Albert Einstein</description>
	<lastBuildDate>Sun, 05 Feb 2012 20:44:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Smart and Simple Mail to SMS Gateway</title>
		<link>http://blog.gurudelleccelsopicco.org/2008/08/smart-and-simple-mail-to-sms-gateway/</link>
		<comments>http://blog.gurudelleccelsopicco.org/2008/08/smart-and-simple-mail-to-sms-gateway/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 15:45:46 +0000</pubDate>
		<dc:creator>Luca Maranzano</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[mail2sms sms mail gateway postfix procmail foxbox]]></category>

		<guid isPermaLink="false">http://gurudelleccelsopicco.wordpress.com/?p=17</guid>
		<description><![CDATA[<p>This is a simple guide for configuring a simple (but smart  ) Mail to SMS gateway.  It is based on the FOX BOX platform for sending out SMS.  You will need a Linux server with the Postfix MTA configured.  Besides, you will need at least the following additional packages:</p>

mimedecode
lynx
URLENCODE.sh shell script [...]]]></description>
			<content:encoded><![CDATA[<p>This is a simple guide for configuring a simple (but smart <img src='http://blog.gurudelleccelsopicco.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> ) Mail to SMS gateway.  It is based on the <a title="FOX BOX SMS Gateway" href="http://www.smsfoxbox.it/" target="_blank">FOX BOX platform</a> for sending out SMS.  You will need a Linux server with the Postfix MTA configured.  Besides, you will need at least the following additional packages:</p>
<ol>
<li>mimedecode</li>
<li>lynx</li>
<li><a href="http://www.acmesystems.it/articles/00080/urlencode.sh">URLENCODE.sh</a> shell script by Heiner Steven (  <a href="mailto:heiner.steven@odn.de">heiner.steven@odn.de</a>) to perform TEXT to URL encoding transforms</li>
<li>formail which is part of the procmail package</li>
</ol>
<p><span style="display:none;">This e-mail address is being protected from spam bots, you need JavaScript enabled to view it </span> You will be able to send an email to an address like smsto+YOURNUMBER@smsgw.yourdomain.com and it will be automagically converted as an SMS containing the sender e-mail and the subject. This implementation is partially derived from <a href="http://www.kdev.it/joomla/index.php?option=com_content&amp;task=view&amp;id=34&amp;Itemid=32" target="_blank">this</a> article.</p>
<p>The destination number must be in the form CCNNNMMMMMMM, with the country code (CC) explicit.</p>
<p>Configure your mail system in order to deliver mail for the smsgw.yourdomain.com through the Postfix box (dedicated server, virtual domain, what ever you prefer).</p>
<p>On the Postfix server make sure that it is configured to use procmail as MDA and that you have the recipient_delimiter defined like this (in /etc/postfix/main.cf):</p>
<pre>mailbox_command = procmail -a "$EXTENSION"
recipient_delimiter = +</pre>
<p>Next create a normal Unix account named &#8220;smsto&#8221;.  Next configure procmail for this account with the following recipe:</p>
<pre>PATH=$HOME/bin:/usr/bin:/bin:/usr/local/bin:.
MAILDIR=$HOME/Mail      # You'd better make sure it exists
DEFAULT=$MAILDIR/mbox
LOGFILE=$MAILDIR/log.`date +%y-%m-%d`
LOCKFILE=$HOME/.lockmail
VERBOSE=yes

SMSDEST=$1

:0
{
        :0 c
        | formail -c -X From: -X Subject: | \
             mimedecode | $HOME/bin/convert2sms.sh $SMSDEST

        :0
        received
}</pre>
<p>Next prepare the following Bash script in $HOME/bin of the smsto user:</p>
<pre>#!/bin/bash

# for debugging
# set -x

if [ $# -ne 1 ]; then
        echo "$0: Please specify the destination phone number (39XXXYYYYYYY)"
        exit 1
fi

# Path to urlencode.sh script
URLENCODE=$HOME/bin/urlencode.sh
# Path to Lynx
LYNX=/usr/bin/lynx
# Where we save the output read from Formail
TEMPFILE=/tmp/smsto.$$
# Clean up when done
trap "/bin/rm -f $TEMPFILE" 0 1 2 3 15

# TODO: check the right pattern of the number
PHONE=$1

while read line; do
        echo "${line}" &gt;&gt; $TEMPFILE
done

# In $TEMPFILE we expect something like this:
# From: some1@somewhere.org
# Subject: the mail subject

# With tr we strip the " char (bug in FOX BOX UI)
# With cut we trim down the size of the field
# We want to stay in the 160 char limit of SMS messages
FROMLINE=`grep -i ^From: $TEMPFILE | tr -d '42' | cut -b -40`
SUBJLINE=`grep -i ^Subject: $TEMPFILE | tr -d '42' | cut -b -117`

logger -i -t SMSTO "$FROMLINE"
logger -i -t SMSTO "$SUBJLINE"

MESSAGE=`echo $FROMLINE \| $SUBJLINE | $URLENCODE`

logger -i -t SMSTO "$MESSAGE"

# Prepare the URL
SENDURL='http://srv-sms/source/send_sms.php?username=Admin&amp;pwd=PASSWORD\
&amp;from=smsgw@yourdomain.com&amp;nphone='$PHONE'&amp;testo='$MESSAGE

CMDS=`$LYNX -dump $SENDURL &gt;/dev/null`

exit 0</pre>
<p>Substitute your SMS BOX Admin password in the SENDURL variable.  It is still rudimentary since some sanity checks are missing, but it works for me. YMMV.</p>
<pre>((enjoy))</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.gurudelleccelsopicco.org/2008/08/smart-and-simple-mail-to-sms-gateway/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

