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


In reply to Continuously Monitor and Handle emails recieved from the 2007 exchange server by sinild

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.