exec_s4.cfg 954 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #
  2. # $Id$
  3. #
  4. # email notification to email address from mysql database
  5. #
  6. fork=no
  7. # ------------------ module loading ----------------------------------
  8. loadmodule "modules/exec/exec.so"
  9. loadmodule "modules/sl/sl.so"
  10. loadmodule "modules/tm/tm.so"
  11. # send email if a request arrives; process statefully
  12. # to avoid multiple execution on request retransmissions
  13. route[0] {
  14. # stop script processing if transaction exists
  15. if ( !t_newtran()) {
  16. sl_reply_error();
  17. break;
  18. };
  19. if (!exec_msg('
  20. QUERY="select email_address from subscriber
  21. where user=\"$SIP_OUSER\"";
  22. EMAIL=`mysql -Bsuser -pheslo -e "$QUERY" ser`;
  23. if [ -z "$EMAIL" ] ; then exit 1; fi ;
  24. echo "SIP request received from $SIP_HF_FROM for $SIP_OUSER" |
  25. mail -s "request for you" $EMAIL '))
  26. {
  27. # exec returned error ... user does not exist
  28. # send a stateful reply
  29. t_reply("404", "User does not exist");
  30. } else {
  31. t_reply("600", "No messages for this user");
  32. };
  33. }