Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

usin perl to Read email

Posted on 2003-11-25
5
Medium Priority
?
454 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 450 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

Industry Leaders: 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

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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

730 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