sinild has asked for the wisdom of the Perl Monks concerning the following question:
Last few days, I am trying hard to find a solution for this, which I failed. Hope you can help me.
I am comfortable with PERL, but not a real expert. For a project, I need to develop a PERL code which monitors an email ID. If any email is recieved, pick the corresponding Subject, From address and Message body and then dump it into the Database.
Here is my email server details:
-This is my company exchange server (MS exchange server 2007).
-As an employee, I too have an email account on this server. I dont have any other access to this exchange server.
-For this new project, IT team created a new email account. My program should monitor this account.
-We have a public webmail, "webmail2.sonicwall.com", which we can use to access emails, when we are out of corporate netywork.
When, I checked with my IT team, they mentioned me that I can use "webmail2.sonicwall.com" in my code to recieve emails.
Here is how I plan to implement this project(Let me know, if there is a better option).
-On my Linux Box, I plan to create a daemon, which will run at startup and will call a PERL script at regular intervals.
-The perl script will have the program to fetch the emails and then to dump to DB
I created a PERL code to access my emails, but it is not working. Here is the code.
use Net::POP3; my $pop = Net::POP3->new("webmail2.sonicwall.com"); my $numInboxMsgs = $pop->login('sdevassy', 'xxxxxx'); unless ($numInboxMsgs) { print "Could not login to pop3 mailbox."; exit 1; } if ($numInboxMsgs eq '0E0') { $numInboxMsgs = 0; } print "Found $numInboxMsgs messages in the Inbox.";
But, this code fails with the error "Could not login to pop3 mailbox.".
Also, I tried the following:
#!/usr/local/bin/perl use Net::IMAP::Client; my $imap = Net::IMAP::Client->new( server => 'webmail2.sonicwall.com', user => 'sdevassy', pass => 'xxxxxx', ssl => 1, # (use SSL? default no) port => 993 # (but defaults are sane) ) or die "Could not connect to IMAP server"; # everything's useless if you can't login $imap->login or die( $imap->last_error);
But, this code fails with the error "LOGIN failed. at /tmp/2test.pl line 16..".
Also, I tried to prefix the domain name along with the username. It too failed. Can you please let me know, what is going wrong. How can I access the emails.
I'm eagerly waiting for your response.
Regards,
Sinil
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Continuously Monitor and Handle emails recieved from the 2007 exchange server
by tobyink (Canon) on Jan 12, 2012 at 13:01 UTC | |
|
Re: Continuously Monitor and Handle emails recieved from the 2007 exchange server
by flexvault (Monsignor) on Jan 12, 2012 at 10:35 UTC | |
by sinild (Initiate) on Jan 13, 2012 at 07:53 UTC | |
by wwe (Friar) on Jan 16, 2012 at 15:05 UTC | |
|
Re: Continuously Monitor and Handle emails recieved from the 2007 exchange server
by Anonymous Monk on Jan 12, 2012 at 10:17 UTC |