-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmissedcall.pl
More file actions
executable file
·37 lines (27 loc) · 836 Bytes
/
missedcall.pl
File metadata and controls
executable file
·37 lines (27 loc) · 836 Bytes
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
#!/usr/bin/perl
use strict;
use warnings;
use Asterisk::AGI;
use Email::Sender::Simple qw(sendmail);
use Email::Sender::Transport::SMTP::TLS;
my @recipients = ('x@y.com');
my $AGI = Asterisk::AGI->new();
my $dialstatus = $AGI->get_variable("DIALSTATUS");
my $callerid = $AGI->get_variable("CALLERID(all)");
my ($number) = ($callerid =~ m/<(.*)>/);
exit if $dialstatus eq 'ANSWER';
my $transport = Email::Sender::Transport::SMTP::TLS->new(
host => 'smtp.gmail.com',
port => 587,
username => '',
password => '',
);
my $message = Email::Simple->create(
header => [
From => 'Missed call',
Subject => "Missed call from $number",
],
body => "Missed call from $callerid",
);
$message->header_set( To => @recipients );
sendmail( $message, { transport => $transport });