On Wed, Apr 11, 2007 at 02:02:44AM -0700, Dilshan Perera wrote:
> Hi Johan,
> First of all let me thank you for your quick response.
> 
> Actually I've been asked to do this with QPSMTPD that's why I need a
> qpsmtpd plugin, and let me complete the requirement.  The 160
> characters will be immediately forwarded to a smsc (sms client) to
> forward it to the receiver, and then look in to the next 160
> characters. The main idea is that not to keep any archive but to
> forward the requested no. of sms's and discard the mail after
> forwarding it to his mail box.
You're still going about this the wrong way. 

Find attached the shell program that I used to use with my cellphone,
before my cell-provider changed their email to SMS gateway (to always
send a very annoying message "You have recieved an email from [EMAIL PROTECTED],
reply with yes to read it")

I was originally calling it the attached program from a .qmail file,
then later procmail so that I could do some special filtering on it
first. In both cases, the email is discarded afterwards instead of
stored.

The core problem, is that there are much better tools than qpsmtpd to
select the 160 characters that you wish to send. My script simply
prepends the content of the subject line to the message, and then takes
the first 140 characters (limit of my cell provider).

-- 
Robin Hugh Johnson
Gentoo Linux Developer & Council Member
E-Mail     : [EMAIL PROTECTED]
GnuPG FP   : 11AC BA4F 4778 E3F6 E4ED  F38E B27B 944E 3488 4E85
#!/bin/bash
CONFIGFILES="/etc/rogerssms ~/.rogerssms"
if [ -z $NUM ]; then
        for i in $CONFIGFILES; do
                f="$(eval echo $i)"
                [ -e $f ] && source $f
        done;
fi
if [ -z "${NUM}" ]; then
        echo "Phone number not set!" 1>&2
        exit 1
fi

TM="$(cat -)"
SPACECMD='sed "s,^[[:space:]]\+,,g;s,[[:space:]]\+, ,g;s,[\n\r], 
,g;s,[[:space:]]\+$,,g;"'
SPACECMD="tr -s '[:space:]' ' ' | ${SPACECMD} | tr -s '[:space:]' ' '"
HEADERS="$(echo -n "${TM}" | formail -X '')"
BODY="$(echo -n "${TM}" | formail -I '' | eval "$SPACECMD" |egrep -v '^$' )"
SUBJ="$(echo -n "${HEADERS}" | formail -c -x Subject | eval "$SPACECMD" )"
MSG="$(echo -ne "${SUBJ} ${BODY}" | head -c140)"

#(
##echo "Message ($SUBJ):"
##echo "---"
##echo "'${BODY}'"
##echo "---"
##echo "Length: ${#BODY}"
#echo -e "(${#MSG}) \n'$MSG'"
#) >>/tmp/rogerstest
URL='http://216.129.53.44:8080/cgi-bin/send_sm_rogers.new'
EMSG="$(echo "${MSG}" | sed 's, ,%20,g;s,\n,%09,g;s,\t,%09,g')"
#echo $MSG
#echo wget --post-data "msisdn=${NUM}&text=${EMSG}&SIZEBOX=${#MSG}" "$URL" 
>>/tmp/rogerstest
#wget --post-data "msisdn=${NUM}&text=${EMSG}&SIZEBOX=${#MSG}" "$URL" -q

smssend rogers.sms ${NUM} "${MSG}"

Attachment: pgp2JLsm4RZu4.pgp
Description: PGP signature

Reply via email to