[asterisk-users] [*Win32 0.60] Sending call notification by e-mail/web?

Vincent Delporte vincent.delporte at bigfoot.com
Mon May 14 22:45:29 MST 2007


Hello,

In case there are other users of the AsteriskWin32 port...

I haven't really used the AGI feature of Asterisk to run an application 
from extensions.conf. *Win32 supports Perl, which I don't know. Apparently, 
it's also possible to write AGI applications as EXE's (there's a 
eagi-test.exe file installed by default).

=> When a call comes in, I'd like an AGI application to send an e-mail and 
send CID name/number to a script on a web server.

Is this the correct way to do it in Perl, with the modules available in 
AsteriskWin32? Could I rewrite this in Delphi instead?

---------------------------------------------------
#!/usr/bin/perl

;---------------------------------------------------
;Note: Not sure if *Win32 supports LWP::Simple and Net::SMTP!

;Called from extensions.conf
;exten => group,n,AGI(notify.agi|${CALLERID(num)}|${CALLERID(name)})

;---------------------------------------------------

use strict;

open STDOUT, '>/dev/null';
fork and exit;

;---------------------------------------------------
use LWP::Simple;

my $cidnum = $ARGV[0];
my $cidname = $ARGV[1];

my $url = 'http://www.acme.com/input.php?name=$cidname&number=$cidnum';
my $content = get $url;
die "Couldn't get $url" unless defined $content;
print STDERR "Notified web server"

;---------------------------------------------------
use Net::SMTP;

$smtp = Net::SMTP->new('smtp.acme.com'); # connect to an SMTP server
$smtp->mail( 'asterisk at acme.com' );     # use the sender's address here
$smtp->to('calls at acme.com');        # recipient's address
$smtp->data();                      # Start the mail

# Send the header.
$smtp->datasend("To: calls at acme.com\n");
$smtp->datasend("From: asterisk at acme.com\n");
$smtp->datasend("\n");

# Send the body.
$smtp->datasend("Call received from $cidname/$cidnum\n");
$smtp->dataend();                   # Finish sending the mail
$smtp->quit;
print STDERR "Send e-mail"
---------------------------------------------------

Thanks for any tip 



More information about the asterisk-users mailing list