User Tools

Site Tools


mail_to_sms_phone_number_subject

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

mail_to_sms_phone_number_subject [2016/06/14 18:35] (current)
Line 1: Line 1:
 +===== Mail to SMS forwarding using phone number as email subject =====
 +This script allows you easily forward email messages to SMS, **using phone number as email subject**.
  
 +<​code>​
 +SHELL=/​bin/​sh
 +VERBOSE=OFF
 +MAILDIR=/​mnt/​flash/​spool/​maildir
 +DEFAULT=/​mnt/​flash/​spool/​mail/​mails
 +LOGFILE=/​var/​log/​procmail.log
 +
 +:0
 +*  ^Subject:.*
 +{
 +:0c:
 +${DEFAULT}
 +:0
 +{
 +#​bW:​mail.body.lock
 +SUBJ_=`formail -xSubject: \
 +      | expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//​g'​ | sed -r '​s/​[+]+//​g'​`
 +#POSI=`expr index "​${SUBJ_}"​ 00`
 +REPLA0=$SUBJ_
 +POSI=`expr substr $REPLA0 1 2`
 +LUN=`expr length $REPLA0`
 +#if [[ $POSI == "​00"​ ]]; then
 +#       ​SUBJ_=`expr substr $REPLA0 3 $LUN`
 +#fi
 +    # Get the body of the message into a variable
 +    # Accept only the first five lines
 +    # Discard newlines, i.e. put everything on one line
 +    BODY_=`sed -e '​1,/​^$/​ d' | head -5 | tr -d '​\n'​`
 +#echo "​${SUBJ_} ${BODY_}"​ > /​var/​test.txt
 +#| /​etc/​sms/​scripts/​email2sms
 +}
 +:​0:​bW:​mail.body.lock
 +| case $POSI in 00) SUBJ_=`expr substr $REPLA0 3 $LUN`;; *) REPLA0=$SUBJ;;​ esac; OUTFILE=$(mktemp /​mnt/​flash/​spool/​outgoing/​smsgw.out.XXXXXX);​echo "​From:​mail\nTo:​${SUBJ_}\n\n${BODY_}"​ > $OUTFILE
 +}
 +</​code>​
mail_to_sms_phone_number_subject.txt ยท Last modified: 2016/06/14 18:35 (external edit)