Reading my mail with a script

software development

#1

I’m trying to user perl to write a script to basically look through my mail for a specific automated message and then it can alert me of it. Anyway, that part’s not important. I can’t get Net::POP3 to connect. Here’s all I have:

my $ServerName = “mail.derekdev.com”;
my $pop3 = new Net::POP3($ServerName) or die(“Couldn’t connect to server”);
my $username = “username”;
my $password = “password”;
my $numMessages = $pop3->login($username, $password) or die(“Couldn’t login to server”);
my $messages = $pop3->list();

And it gives me this:

Couldn’t login to server at mail.pl line 42.

Yes, I’ve checked the username and password, and yes I edited them out of this code. What else do I need to get it to connect? Something more than the username and password maybe? I’m pretty sure we don’t have a pre-installed PHP module to do this or else I’d use PHP. I don’t want to learn Python syntax (tho I should one of these days anyway). Maybe there’s another simpler option? I really hate perl, but I’ll use it if I have to.


#2

Hey, this still doesn’t work. I’ve tried IMAP and now POP3Client. Nothing can log in even tho I know the username and password are correct. They’re just little words and I can log in when I copy and paste them into the squirel mail login page. Does anyone have any clue? I read in the kb to use port 995.

my $socket = IO::Socket::SSL->new(PeerAddr => “mail.derekdev.com”, PeerPort => 995, Proto => “tcp”) or die(“Couldn’t create socket.”);
my $pop3 = Mail::POP3Client->new();
$pop3->User($username);
$pop3->Pass($password);
$pop3->Socket($socket);
$pop3->Connect();
print($pop3->Message());

gives

PASS failed: -ERR Login failed.


#3

for the user name do you need to be using the m123456 login, instead of what works for webmail? That’s what you have to do if you install your own webmail client, not sure if that applies to what you’re trying to accomplish, but it probably does.

-Matttail


#4

Whoa, that did it. Finally. Thanks. Dreamhost is weird sometimes.