Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Reading mail from an exchange mailbox, no Outlook

by girarde (Friar)
on Sep 23, 2010 at 20:59 UTC ( #861660=perlquestion: print w/ replies, xml ) Need Help??
girarde has asked for the wisdom of the Perl Monks concerning the following question:

I have a job that sends email to an organizational box. I have a script that runs as a user that has Full Control of that org box's associated account in an Active Directory 2003 domain.

The script runs on a Windows 2003 server that does not, and will not, have Outlook installed.

Authen::NTLM does not seem to be willing to use the current user's credentials. Any ideas for how to read this mail into the script without installing a client?

UPDATE:

I am also using Email::Folder::Exchange, which is what is complaining about not having credentials available. Snippet below:

#!/c/perl/bin/perl use strict; use warnings; use Email::Folder::Exchange; use Authen::NTLM; my $user = ntlm_user(); my $password = ntlm_password(); my $folder = Email::Folder::Exchange->new('https://fqdn.com/Exchange/o +rgbox/Inbox', $user, $password); my $pile; for my $message ($folder->messages) { if ($message->header('Subject') =~ /Addition to EPAS Training Sit +e for 18 FLTS/) { $pile .= $message->body; last; } } print $pile; exit;

Comment on Reading mail from an exchange mailbox, no Outlook
Select or Download Code
Re: Reading mail from an exchange mailbox, no Outlook
by bellaire (Hermit) on Sep 24, 2010 at 00:55 UTC

    Looking at the source to Authen::NTLM, there is nothing in there that will grab the username and password for the currently logged in user. In fact, I'd venture to say that it's not possible to obtain the cleartext password for the current user. All the ntlm_password() sub does is to return a password you set earlier by using, for example, the new contructor for Authen::NTLM.

    Unfortunately, if you don't have a way of actually obtaining the username and password (e.g. from a configuration file) to use in this script, I don't think this approach is going to work for you. And, while I'm no expert with Win32 in Perl, I don't know of any approach that will, short of installing Outlook.

Re: Reading mail from an exchange mailbox, no Outlook
by tokpela (Chaplain) on Sep 24, 2010 at 01:26 UTC

    Reading the documentation for Email::Folder::Exchange, it looks like this module works through the Outlook Web Access.

    If you do not have Outlook Web Access enabled and want to access an Exchange Server without Outlook, you will have to use CDO (Collaboration Data Objects) which provide a COM based API to connect to a MAPI store.

    I connected to Exchange through Perl using Outlook Redemption which allowed for better script integration.

    As for getting the current user and password information, I am not sure how this would not be a major security hole!

    I have not tried the Win32::IntAuth but maybe this would allow you to impersonate your Exchange user and connect via CDO/RDO as mentioned above.

      I do have an OWA server available, it's merely that Outlook will not be installed on the server that script will be running on. I'll check CDO and the other modules.

        girarde:

        You don't need Outlook to access the OWA server. You can do just fine with normal web access (e.g. LWP). I had a similar problem a few years back, and that's how we got around it. (Note: "We" as in "Someone else on my team did the work".)

        ...roboticus

Re: Reading mail from an exchange mailbox, no Outlook
by afoken (Parson) on Sep 24, 2010 at 04:12 UTC

    Try the internet standard protocols, i.e. SMTP to send (TCP port 25 or 587), POP3 (TCP port 110) or IMAP4 (TCP port 143) to receive. Those protocols are often enabled on Exchange servers, if not, talk to the server's administrator. As soon as you know that those protocols work, forget that you are "talking" with an Exchange server and work like you would do with any other internet mail server.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      POP3 and IMAP4 are not enabled on the mail server, and they WILL NOT be enabled there. This decision was made at echelons above reality.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://861660]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (16)
As of 2014-07-10 13:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (210 votes), past polls