so I have been messing with this for the last couple of hours and I'm getting no place. Below is the code I now have in automail.pl. Only problem is I get the following errors when I run it. Any clue how to resolve these?
ERRORS:
syntax error at ./automail.pl line 32, near "$msg ("
BEGIN not safe after errors--compilation aborted at ./automail.pl line 49.
CODE:
#!/usr/bin/perl
#######################################################################
# automail.pl
#
# Perl script used for remote email piping...same as as the PHP version.
#
# Peter Rotich <peter@osticket.com>
# Copyright (c) 2006,2007 osTicket
# http://www.osticket.com
#
# Released under the GNU General Public License WITHOUT ANY WARRANTY.
# See LICENSE.TXT for details.
#
# vim: expandtab sw=4 ts=4 sts=4:
# $Id: $
#######################################################################
#Configuration: Enter the url and key. That is it.
# url=> URL to pipe.php e.g http://yourdomain.com/support/api/pipe.php
# key=> API Key (see admin panel on how to generate a key)
%config = (url => 'http://MYURL.COM/api/pipe.php',
key => '0A73932E7B32F663E6DC87F421BE33FC');
use Net::;
# open a connection to the IMAP server
$server = new Net::( '000.000.000.000' );
# login
$server->login( 'username', 'password' );
#get number of emails in the inbox
$number_of_messages = $server->select( 'INBOX' )
#step through each email, add it to the $rawemail var
#and then delete the email from the server
foreach $msg (1..$number_of_messages) {
if ( !$server->seen( $msg )) {
$rawemail .= $msg;
}
$server->delete( $msg );
}
#Get piped message from stdin
#while (<STDIN>) {
# $rawemail .= $_;
#}
use LWP:;
$ua = LWP:->new;
$ua->agent($config{'key'});
$ua->timeout(30);
use HTTP:: qw(POST);
my $enc ='text/plain';
my $req = (POST $config{'url'}, Content_Type => $enc,Content => $rawemail);
$response = $ua->request($req);
#
#Process response
# Depending on your MTA add the exit codes
#
if($response->is_success and $response->code==200 and length($response->content)==1) {
#print "Success";
}else {
#print "Error ".$response->content;
}
exit;