SMS Server Tools 3
This site is hosted by Kekekasvi.com
 Menu
Basic information:
Additional information:
Support:
Get SMS Server Tools 3:
Additional Options

 Sponsored links

 Search
Custom Search

 Visitor locations
 
 SMS Server Tools 3 Community
Welcome, Guest. Please login or register. Sat Apr 20, 2024 00:51
SMSTools3 Community » Sample scripts / setups Bottom

[answered] Multiple recipients

Login and Post Reply

Page:  1

Author Post
Member
Registered:
Dec 2010
Location: DKI Jakarta, Indonesia
Hi Keke,

I have read this post, based on that I have some questions to ask you about.

1. Does the checkhandler read the files from Outgoing folder?
2. I have saved a file (from html) that has many "To:" header and also the body of the message at the end, but why I only be able to send message for the last "To: recipient" ?
3. I have seen the mysql table (sms_log) that all the To: recipients are stored on the same column (receiver), is there any way to break those To: recipients and store the number on the column one by one?

Thank you in advance.

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
maulana23 wrote
1. Does the checkhandler read the files from Outgoing folder?

Yes, the sample checkhandler reads /var/spool/sms/outgoing.

maulana23 wrote
2. I have saved a file (from html) that has many "To:" header and also the body of the message at the end, but why I only be able to send message for the last "To: recipient" ?

It sounds like you have not defined checkhandler in the smsd.conf. When checkhandler does not modify the message file, smsd will read all To: headers and only the latest value is used. Assuming that you have stored the script as /usr/local/bin/smsd_checkhandler.sh, in the global part of smsd.conf (top of a file) define:
checkhandler = /usr/local/bin/smsd_checkhandler.sh

maulana23 wrote
3. I have seen the mysql table (sms_log) that all the To: recipients are stored on the same column (receiver), is there any way to break those To: recipients and store the number on the column one by one?

Have you checked this topic: Sample eventhandler to store messages into SQL database?

Member
Registered:
Dec 2010
Location: DKI Jakarta, Indonesia
Topic owner
Thank you for your quick response Keke.

keke wrote
It sounds like you have not defined checkhandler in the smsd.conf. When checkhandler does not modify the message file, smsd will read all To: headers and only the latest value is used. Assuming that you have stored the script as /usr/local/bin/smsd_checkhandler.sh, in the global part of smsd.conf (top of a file) define:
checkhandler = /usr/local/bin/smsd_checkhandler.sh

is .sh extension required on the file name?

keke wrote

Yes, I have read it, and I have used it for a normal (single recipient) sms. When I use it for multiple recipients, all the recipients are stored into the same column and are counted as 1 value.

What I was trying to ask is that, if I send to multiple recipients
for example:


So, can it be stored to mysql into 2 values (different recipients but the same message)?
The values that will be stored into mysql:


Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
.sh extension is not required. It is used because some editors do not apply syntax highlight without it. It also tells that the file is shell script, ls *.sh can be used.

Your system does not run checkhandler properly. Ensure that you have correct script in correct place, and have checkhandler = /path/to/your/checkhandler defined in the smsd.conf. After changing the configuration, you need to restart the smsd.

If you still do not get the system working, show the smsd.conf here, and also the checkhandler script, if you have modified it. Tell what version of smsd you are running, and on what OS.

Member
Registered:
Dec 2010
Location: DKI Jakarta, Indonesia
Topic owner
First of all, Happy New Year mate, and sorry for the late reply.


Below is my checkhandler file and to be honest, I copied the whole thing from the post to my server without any changes to be made.


Here is my smsd.conf


I'm using version 3 of smstools and it is running on FreeBSD v8.0 OS

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Probably you do not have formail program available. Try which formail, and if it is not found, install procmail package. Latest versions of smsd will also show error messages in the log, if checkhandler encounters any errors.

Member
Registered:
Mar 2011
Location: Madrid, Spain, Spain
Hello i am trying without sucess update this script for make it work with Accentuated character conversion like is describe in http://smstools3.kekekasvi.com/topic.php?id=166 can someone help me doing that? thanks Alot.

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
angeldark wrote
Hello i am trying without sucess update this script for make it work with Accentuated character conversion like is describe in http://smstools3.kekekasvi.com/topic.php?id=166 can someone help me doing that? thanks Alot.

Something like this:

#!/bin/bash

# Sample script to allow multiple recipients in one message file.
# Define this script as a checkhandler.

outgoing="/var/spool/sms/outgoing"

recipients=`formail -zx "To:" < "$1"`

#count=`echo "$recipients" | wc -l`
count=`echo "$recipients" | wc -w`
if [ $count -gt 1 ]; then

  # Will need echo which accepts -n argument:
  ECHO=echo
  case `uname` in
    SunOS)
      ECHO=/usr/ucb/echo
      ;;
  esac

  messagebody=`sed -e '1,/^$/ d' < "$1"`
  headers=`formail -X "" -I "To:" -f < "$1"`

  for recipient in $recipients
  do
    file=`mktemp $outgoing/send_XXXXXX`
    $ECHO "To: $recipient" > $file
    if [ "x$headers" != "x" ]; then
      $ECHO "$headers" >> $file
    fi
    $ECHO "" >> $file
    $ECHO -n "$messagebody" >> $file

    if sed -e '/^$/ q' < "$file" | grep "^Alphabet: UTF-8" > /dev/null; then
      TMPFILE=`mktemp /tmp/smsd_XXXXXX`
      sed -e '/^$/ q' < "$file" | sed -e 's/Alphabet: UTF-8/Alphabet: UCS2/g' > $TMPFILE
      sed -e '1,/^$/ d' < "$file" | iconv -f UTF-8 -t UNICODEBIG >> $TMPFILE
      mv $TMPFILE "$file"
    fi

  done

  # Remove processed file:
  rm $1

  # Tell to smsd that checkhandler has spooled this message:
  exit 2
fi

exit 0
 
 
'bash' Syntax Highlight powered by GeSHi


Member
Registered:
Mar 2011
Location: Madrid, Spain, Spain
In fact it was more easy that i was trying to do...
thanks for your replay i have it almost done, there is only on prob. i cant get some acentuate charset like á à ã every all are working fine.

there is my code:



Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
When the conversion is done inside the loop, a variable $file must be used instead of $1.

However, the loop is not executed if there is only one recipient in the SMS file. The following version makes the conversion once, and with single recipient too. Also note, that SMS file must include a header "Alphabet: UTF-8" when it is known that there are characters outside the GSM alphabet.

#!/bin/bash

# Sample script to allow multiple recipients in one message file.
# Define this script as a checkhandler.

outgoing="/var/spool/sms/outgoing"

if sed -e '/^$/ q' < "$1" | grep "^Alphabet: UTF-8" > /dev/null; then
  TMPFILE=`mktemp /tmp/smsd_XXXXXX`
  sed -e '/^$/ q' < "$1" | sed -e 's/Alphabet: UTF-8/Alphabet: UCS2/g' > $TMPFILE
  sed -e '1,/^$/ d' < "$1" | iconv -f UTF-8 -t UNICODEBIG >> $TMPFILE
  mv $TMPFILE "$1"
fi

recipients=`formail -zx "To:" < "$1"`

#count=`echo "$recipients" | wc -l`
count=`echo "$recipients" | wc -w`
if [ $count -gt 1 ]; then

  # Will need echo which accepts -n argument:
  ECHO=echo
  case `uname` in
    SunOS)
      ECHO=/usr/ucb/echo
      ;;
  esac

  messagebody=`sed -e '1,/^$/ d' < "$1"`
  headers=`formail -X "" -I "To:" -f < "$1"`

  for recipient in $recipients
  do
    file=`mktemp $outgoing/send_XXXXXX`
    $ECHO "To: $recipient" > $file
    if [ "x$headers" != "x" ]; then
      $ECHO "$headers" >> $file
    fi
    $ECHO "" >> $file
    $ECHO -n "$messagebody" >> $file
  done

  # Remove processed file:
  rm $1

  # Tell to smsd that checkhandler has spooled this message:
  exit 2
fi

exit 0
 
 
'bash' Syntax Highlight powered by GeSHi


Member
Registered:
Mar 2011
Location: Madrid, Spain, Spain
Thanks i will make a try and get you know. thanks

Login and Post Reply

Page:  1

SMSTools3 Community » Sample scripts / setups Top

 
Time in this board is UTC.  

Privacy Policy   SMS Server Tools 3 Copyright © Keijo Kasvi.