Click to See Complete Forum and Search --> : Help. COM, MAPI, Classfactory Error


timlckuk
12-05-2001, 06:26 AM
Hi,

Has anyone succeeded in getting PHP to send mail via a MAPI.Session COM object through an Exchange Server 5.5 account? I've been banging my head against several brick walls on this subject for the last 24 hours.

Turns out our client (who we've developed an intranet for) has disabled all SMTP traffic within their network due to security issues, so the standard PHP mail() function just won't cut it in this case.

Here's my sample code:

<?php

echo("Starting Mapi Session<br>");
$objSession = new COM('MAPI.Session');
$objSession->Logon("Profilename", "Password");

echo("Opening Outbox to add a new message<br>");
$objMessage = $objSession->Outbox->Messages->Add();
$objMessage->Subject = "Test message";
$objMessage->Text = "This is a sample message";

echo("Adding recipient to message<br>");
$objRecipient = $objMessage->Recipients->Add();
$objRecipient->Name = "someone@somewhere.com";
$objRecipient->Type = 1;
$objRecipient->Resolve();

echo("Updating and sending...");
$objMessage->Update();
$objMessage->Send(False);
echo("All done<br>");

?>

This code works just fine in a VB application, unfortunately when ported to PHP as above, I get nothing but this pointless and seemingly unsupported error message.

Warning: Invoke() failed: ClassFactory cannot supply requested class in c:\www\default\html\mapimailtest.php on line 5

This is the line where the $objSession.Logon() method is called. Now this error usually happens when a COM class is not properly registered, but if it wasn't, then it wouldn't work in VB right (I do however have to add CDO to the project references)?

Any ideas extremely gratefully recieved...even if it involves using something else...

Thanks,
Tim

OS/Platform:
Windows 2000 Professional (SP2)
Outlook 2000 (SP1a with Collaboration Data Objects option)
Apache 1.3.2
PHP 4.0.6

timlckuk
12-05-2001, 07:36 AM
Addendum...

This looks like it may be related to running Apache as a Service. If I run using PHP.EXE or Apache standalone exe, it works like a charm...

I've tried setting the user account for the service, but no joy.

Is apache likely to stand up to the likely abuse if it's run as a standalone?

Anon
03-29-2002, 07:37 AM
Did you find a solution to this problem and still run apache as a service?