Read email by a script !


Is there a away, a script, can read my emil message and store them in a file and then I can open this file from a Web page, so if I am away from my machine I can read my old+new email messages from this file. I don't know if that possible. Thanks

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oualideAuthor Commented:
Edited text of question.
Where do you get your email messages from?  From a file?  From a POP3 server?  From SMTP?
In what language would the script be written?
Would you need to prevent others from reading your mail?
oualideAuthor Commented:
From pop3 server.
It doesn't matter but Perl is perferable.
I can hide it in my Web server. I mean no link and I put it under a proteted dir which I usualy access by a username + password.

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

#you could
use Mail::POP3Client;
use Net::POP3;
oualideAuthor Commented:
How difficult ?

Will I have control over the my email messages. I mean every time you run the script, can you read only new messages.

Is there an alternative to this approach ?



You can open a connection to your own, or any other pop3 mail server by opening a connection to it using port 110 (the pop3) port and the name of the host.

The commands that you need are then:
user <user-name>
pass <password>
stat - shows what is waiting
retr n - gets message number n
dele n - deletes message n
quit - closes the connection

If you use telnet to your mail server you can test all this and see what your perl needs to do.  I have a script that I use to do exactly what you want, I use it so that I can collect eMail from multiple pop3 boxes and access it from any web-browser.  This way when I am on the road I just get to anyone's browser and check my mail.

Sadly, there is more in the script than I want to give you for somewhat obvious reasons.  But feel free to ask anything that is not clear here.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
oualideAuthor Commented:

Thanks for the help butcan you show me a little example in per how to connect and read. I have not seen this anywhere before.
I use perl sometimes anh have books but tis never mentioned.
Thanks agian

This works, to show how many messages are waiting:

use IO::Socket;
$EOL = "\015\012";
$BLANK = $EOL x 2;

    $remote = IO::Socket::INET->new( Proto     => "tcp",
                                     PeerAddr  => $host,
                                     PeerPort  => "pop3(25)",
    unless ($remote) { die "cannot connect to http daemon on $host" }
    print $remote "user yourusername" . $EOL;
    print $remote "pass yourpw" . $EOL;
    print $remote "stat" . $EOL;
    print $remote "quit" . $EOL;
    while ( <$remote> ) { print;

    close $remote;
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.