sara ibn el ahrache has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/env perl use strict; use warnings; use Mail::IMAPClient; use IO::Socket::SSL; use IO::File; use Mail::IMAPClient::MessageSet; use Mail::IMAPClient::BodyStructure; use MIME::Parser; # Connect to the IMAP server via SSL my $socket = IO::Socket::SSL->new( PeerAddr => ' imap.gmail.com ', PeerPort => 993, ) or die "socket(): $@"; # Build up a client attached to the SSL socket. # Login is automatic as usual when we provide User and Password my $client = Mail::IMAPClient->new( Socket => $socket, User => 'sara.ibnelahrache', Password => 'saraibnelahrache', ) or die "new(): $@"; $client->select('INBOX'); my $i = $client->message_count; my $msgString = $client->body_string($i); my $newtxt = ''; my $parser = new MIME::Parser; $parser->output_under('/tmp'); $parser->decode_headers(1); $parser->extract_nested_messages(0); $parser->ignore_errors(1); my $entity = $parser->parse_data($msgString); if ($entity->bodyhandle) { $newtxt = $entity->bodyhandle->as_string; } elsif ($entity->parts > -1) { $newtxt = $entity->parts(0); } else { $newtxt = "Unable to parse message text!"; } my $text = qq($newtxt); my $sounddir = "/var/lib/asterisk/sounds"; my $wavefile = "$sounddir/"."message.wav"; my $wavefileAst = "$sounddir/"."message"; my $t2wp= "/opt/swift/bin/"; unless (-f $wavefile) { open(fileOUT, ">$sounddir"."/message.txt"); print fileOUT "$text"; close(fileOUT); my $execf=$t2wp."swift -f $sounddir/message.txt -p audio/channels= +1,audio/volume=70,audio/sampling-rate=8000,audio/deada$ system( +$execf); unlink($sounddir."/message.txt"); } ###################################################################### +################################################ #Say bye $client->logout();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: mail::imapclient + gmail + mmap() invalid argument
by jethro (Monsignor) on May 26, 2009 at 23:36 UTC | |
|
Re: mail::imapclient + gmail + mmap() invalid argument
by Perlbotics (Archbishop) on May 27, 2009 at 18:12 UTC |