[asterisk-users] Sending Email From the dialplan

Joanna Liza Mariazeta joannaliza at gmail.com
Mon Feb 26 03:44:50 MST 2007


Hi Al,

We have different email contents and subject  depending in the action that
the customer had taken, since our service is a Prepaid card. What I did, was
to use an AGI to have this flexibility. After getting the caller id and
querying it in the DB, I will then construct the email that will be sent to
the  customer.

[nihonggo-temporary-registration]
exten => readnum,1,Set(REGPHONE=${CALLERIDNUM})
exten => 2,1,AGI(preRegist.agi,${REGPHONE})
exten => 2,2,AGI(sendEMAILnotification.agi,${REGPHONE})

AGI script..

sub mailSend {
    my ($subj, $body) = @_;
    my(@da, @day, @mon, $datetime, $expTO, $mail, $head);
    @da = localtime(time);
    @day = qw(Sun Mon Tue Wed Thu Fri Sat);
    @mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
    $datetime = sprintf "%s, %02d %s %d %02d:%02d:%02d +0900",
             ($day[$da[6]], $da[3]*1, $mon[$da[4]], $da[5]+1900,
              $da[2]*1, $da[1]*1, $da[0]*1);

    $body = Jcode->new($body)->h2z->jis;

    $head  = "Return-Path: <$m_RETPATH>\n";
    $expTO = join(",\n    ", @m_MAILTO);
    $head .= "To: $expTO\n";
    $head .= "From: $m_FROM\n";
    $head .= "Date: $datetime\n";
    $head .= "Content-type: text/plain; charset=iso-2022-jp\n";
    $head .= "Subject: $subj\n";
    $head .= "\n";

    $head = &mimeencode($head);

    $mail = "$head$body";

    if (open (OUT, "|$QIPATH")) { # qmail-inject
        $mail =~ s/%/%%/g;
        printf OUT "$mail";
        close (OUT);
    }
}

Hope that helps.

Best Regards,
Joanna
www.mariazeta.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20070226/350de5b6/attachment.htm


More information about the asterisk-users mailing list