Solved

usin perl to Read email

Posted on 2003-11-25
5
450 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
  • 3
  • 2
5 Comments
 
LVL 24

Expert Comment

by:shivsa
ID: 9822824
0
 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

777 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