Solved

usin perl to Read email

Posted on 2003-11-25
5
453 Views
Last Modified: 2010-03-04
Hi All
I need to read an email every time "X email account" receives mails using perl and
i only want to print the subject of the received mail to the screen. thanks in advance
any help will be apriciated.

chz
0
Comment
Question by:Thlware
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 2

Author Comment

by:Thlware
ID: 9822869
I have a registered email account on a mail sever pop3 i just need to monitor and  print the subject of emails every time there is a new mail.

chz
0
 
LVL 24

Accepted Solution

by:
shivsa earned 225 total points
ID: 9822979
First, u have to install mail pop 3 client.

download and install in the standard way (it doesn't require a compiler)

http://perl.com/cgi-bin/cpan_mod?module=Mail::POP3Client

After that's installed, try the following (make sure to put in the name of your pop server, as well as the appropriate user name and password):

use strict;
use Mail::POP3Client;

my($POPServer) = 'pop3.mail.com';
my($user) = 'me';
my($password) = 'secret';

my($pop) = new Mail::POP3Client($user, $password, $POPServer) ||
      die "Unable to connect to $POPServer";

my($count, $i);
if ($count = $pop->Count) {
    print "$count Message";
    print 's' if $count > 1;
    print " Found:\n";

    for($i = 1; $i <= $count; $i++) {
        foreach ($pop->Head($i)) {
            print "\t$_\n" if m/^Subject/;
        }
    }
} else {
   print "No Messages found\n";
}

thanks to b2pi.

0
 
LVL 2

Author Comment

by:Thlware
ID: 9823041

Mail::POP3Client; this module seems to be a Unix/linux type module is there alternative module for windows
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9823061
it does not matter as long as perl is using this module, syntex in perl is same on unix/windows.
try to install it and see of this script solve your things.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question