LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Get list of emails through telnet (https://www.linuxquestions.org/questions/linux-software-2/get-list-of-emails-through-telnet-599035/)

yogaboy2 11-12-2007 09:11 AM

Get list of emails through telnet
 
Hi,

I'm trying to get a list of the message in a user's email account, so that I can do some data extraction with perl on the entire list.

So, I thought I might get the list into perl by connecting via telnet to the Exim server. I'm trying it "by hand" before I write the script.
I can authenticate but I'm unsure of how to see the list of messages.


I don't run the email server, can't get any scripts onto it. Our company bought the user's business and he hosts his mail elsewhere until we can migrate him, but I've got work to do in the meantime!


Any insight is much appreciated.

gilead 11-12-2007 01:31 PM

Does the server support IMAP? YOu may be able to send IMAP commands to the server to do this. The RFC at http://www.isi.edu/in-notes/rfc3501.txt describes communication with the server.

nx5000 11-13-2007 04:28 AM

mutt can make complex search on emails. But I don't know if it can be done through imap (so that you don't need to locally download all messages). If they are local then mutt could help you.
Otherwise, I would look at the rfc as mentionned above and DIY..

senramesh 11-13-2007 06:14 AM

Try the below method to list the mails in a mailbox, using telnet...

$ telnet thedomain.com 110
Trying 69.36.162.5...
Connected to thedomain.com.
Escape character is '^]'.
+OK Qpopper (version 4.0.4, modified by Sphera Technologies) ready.
USER janedoe@thedomain.com
+OK Password required for janedoe.
PASS topsecret
+OK janedoe has 5 visible messages (0 hidden) in 39867 octets.
LIST
+OK 5 visible messages (39867 octets)
1 8132
2 10101
3 11861
4 5710
5 4063
.
QUIT
+OK Pop server at thedomain.com signing off.

Connection closed by foreign host.

yogaboy2 12-09-2007 06:09 PM

#!/usr/bin/perl
sorry for not replying immediately - i meant to but then was deluged with work and am only now getting through the backlog!

Thanks for all the tips, here is the perl script I finally used that worked for me. Again, thanks for taking the time to reply, it really is much appreciated.

use warnings;
use strict;
use Mail::POP3Client;

my $pop = new Mail::POP3Client( USER => "myaddress\@mydomain.com"
, PASSWORD => "password"
, HOST => "mail.mydomain.com" );
for (my $i = 1; $i <= $pop->Count(); $i++) {
foreach ( $pop->Head( $i ) ) {
/^(From|Subject):\s+/i and print $_, "\n";
}
print "\n";
}


All times are GMT -5. The time now is 02:32 PM.