Asterisk Imap Email

I Came across this Here

# AGI Script that reads back e-mail from an IMAP account.
# Requires the Asterisk::AGI, Net::IMAP::Simple, and Email::Simple modules.
# Written by: Black Rathchet (blackratchet@blackratchet.org)
# http://www.oldskoolphreak.com

use Net::IMAP::Simple;
use Email::Simple;
use Asterisk::AGI;
use File::Basename;
use Digest::MD5 qw(md5_hex);

my $server = 'localhost'; #INSERT YOUR SERVER HERE
my $username = 'mailuser'; #INSERT YOUR USERNAME HERE
my $password = 'password'; #INSERT YOUR PASSWORD HERE

sub speak(){
$text = $_[0];

my $hash = md5_hex($text);

my $ttsdir = "/var/lib/asterisk/sounds/tts";
my $cepoptions = "-p audio/sampling-rate=8000,audio/channels=1";

my $wavefile = "$ttsdir/tts-$hash.wav";

unless (-f $wavefile) {

open(fileOUT, ">/var/lib/asterisk/sounds/tts/say-text-$hash.txt");
print fileOUT "$text";

my $execf="/opt/swift/bin/swift -f $ttsdir/say-text-$hash.txt -o $wavefile $cepoptions";

$filename = 'tts/'.basename('tts/'.basename($wavefile,".wav"));

$AGI = new Asterisk::AGI;

my %input = $AGI->ReadParse();

# Create the object
my $imap = Net::IMAP::Simple->new($server) ||
die "Unable to connect to IMAP: $Net::IMAP::Simple::errstr\n";

# Log on
&speak("Login failed: " . $imap->errstr . "\n");

# Print the subject's of all the messages in the INBOX
my $nm = $imap->select('INBOX');

for(my $i = 1; $i <= $nm; $i++){

my $es = Email::Simple->new(join '', @{ $imap->top($i) } );

&speak("1, Play, 2, Next, Pound, Exit");


Created by: kFuQ, Last modification: Sun 02 of Oct, 2005 (13:58 UTC)
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+