1#
2# $Id$
3#
4# email notification to email address from mysql database
5#
6
7# ------------------ module loading ----------------------------------
8
9#set module path
10mpath="/usr/local/lib/kamailio/modules/"
11
12loadmodule "exec.so"
13loadmodule "sl.so"
14
15# send email if a request arrives
16route[0] {
17     if (!exec_msg('
18	QUERY="select email_address from subscriber
19		where user=\"$$SIP_OUSER\"";
20	EMAIL=`mysql  -Bsuser -pheslo -e "$$QUERY" kamailio`;
21	if [ -z "$$EMAIL" ] ; then exit 1; fi ;
22	echo "SIP request received from $$SIP_HF_FROM for $$SIP_OUSER" |
23	mail -s "request for you" $$EMAIL ')) {
24		# exec returned error ... user does not exist
25		sl_send_reply("404", "User does not exist");
26	} else {
27		sl_send_reply("600", "No messages for this user");
28	};
29
30}
31