File: email2sms

package info (click to toggle)
smstools 3.1.15-1.1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 1,656 kB
  • ctags: 879
  • sloc: ansic: 14,857; sh: 1,195; php: 115; makefile: 48; awk: 17
file content (44 lines) | stat: -rwxr-xr-x 1,132 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh

# Smsd can send eMails via SMS. You simply need to store the eMail as text
# file in the outgoing queue directory with a unique filename.

# The eMail must include the phone number in the To: field, for example:
# To: "Herbert +491721234567" <sms@localhost>

# This simple script creates a unique filename and copies the eMail from
# stdin to that file.

# If you use procmail to deliver local eMail. Create the user sms and create
# the file /home/sms/.procmailrc with this content:

# VERBOSE=off
# MAILDIR=/var/spool/mail
# DEFAULT=/var/spool/mail/sms
# LOGFILE=/var/log/procmail
# 
# :0
# * ^TOsms
# | /usr/local/bin/email2sms



# If you use QMail and vpopmail you need the file
# /home/vpopmail/domains/your-domain/.qmail-sms with this content:

# | /usr/local/bin/email2sms



tmp=$(mktemp /tmp/smsgw.XXXXXX)
cat >$tmp
destinations=`formail -zx "To:" < $tmp`
IFS=,
for destination in $destinations; do
  destination=${destination## }
  OUTFILE=$(mktemp /var/spool/sms/outgoing/smsgw.out.XXXXXX)
  formail -f -I "To: $destination" < $tmp > $OUTFILE
  chmod 666 $OUTFILE
  echo "SMS queued to $OUTFILE"
done
rm $tmp