7 if ($cmdpath eq "") { $cmdpath="./"; }
9 unshift(@INC,$cmdpath."lib");
10 require "property.pl";
15 $config_file=$cmdpath."smsreceiver.config";
17 ### no configuration beyond this line
19 $props=&Property::read($config_file);
23 tie *LOGFILE, 'Logfile', $$props{'public'}{'logfile'}, 'SMSRECEIVER';
25 print LOGFILE "Connecting to ".$$props{'db'}{'dsn'}." as user ".$$props{'db'}{'user'}."\n";
29 $dbh=DBI->connect($$props{'db'}{'dsn'},$$props{'db'}{'user'},$$props{'db'}{'passwd'});
31 print LOGFILE "Error while connecting DB\n";
34 $table=$$props{'mail'}{'table'};
37 $mo_insert_q="insert into $table (produced,type_sms,message,created) values (?,?,?,NOW())";
38 $mo_insert_sth=$dbh->prepare($mo_insert_q);
43 if (/^Subject: (.*)/i) {
49 if (/^Content-type:\s+(.*)/i) {
57 push(@contentdata,$_);
61 ### filter out mime-crap
63 if ((defined $content_type)&&($content_type!~m#^text/plain#i)) {
64 print LOGFILE "Got mime-mail: $from ($subject) ".localtime(time)."\n";
65 print LOGFILE "Content: ".join('',@contentdata)."\n";
69 ### try to identify sms
71 if ($from=~/^\+?\d+\@/) {
72 ### coming from an emailaccount with a telefon number as user-part in From:
74 ### sms is in first line of body
75 $text=shift(@contentdata);
80 $text=join('',@contentdata);
84 print LOGFILE "$type: $text\n";
85 $mo_insert_sth->execute(0,$type,$text);