Solved

usin perl to Read email

Posted on 2003-11-25
5
448 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
Comment Utility
0
 
LVL 2

Author Comment

by:Thlware
Comment Utility
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
Comment Utility
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
Comment Utility

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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now