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
|
#
# $Id$
#
# email notification to email address from mysql database
#
fork=no
# ------------------ module loading ----------------------------------
loadmodule "modules/exec/exec.so"
loadmodule "modules/sl/sl.so"
loadmodule "modules/tm/tm.so"
# send email if a request arrives; process statefully
# to avoid multiple execution on request retransmissions
route[0] {
# stop script processing if transaction exists
if ( !t_newtran()) {
sl_reply_error();
break;
};
if (!exec_msg('
QUERY="select email_address from subscriber
where user=\"$SIP_OUSER\"";
EMAIL=`mysql -Bsuser -pheslo -e "$QUERY" ser`;
if [ -z "$EMAIL" ] ; then exit 1; fi ;
echo "SIP request received from $SIP_HF_FROM for $SIP_OUSER" |
mail -s "request for you" $EMAIL '))
{
# exec returned error ... user does not exist
# send a stateful reply
t_reply("404", "User does not exist");
} else {
t_reply("600", "No messages for this user");
};
}
|