繁体   English   中英

使用Outlook 2010从PHP发送邮件

[英]Send a mail using Outlook 2010 from php

我正在尝试通过PHP应用程序通过已安装的Outlook 2010客户端发送邮件到目前为止,我已经尝试过建议,评分最高的答案对我而言不起作用。 然后我加了

[COM_DOT_NET]
extension=php_com_dotnet.dll

php.ini的末尾(C:/ xampp / php)。

我还检查了EnableDCOM注册表,将其设置为'Y'

这是我正在使用的代码:

<?php
if (!defined("olMailItem")) {define("olMailItem",0);}
$oApp  = new COM("Outlook.Application") or die('error');
$oMsg = $oApp->CreateItem(olMailItem);
$oMsg->Recipients->Add("xxx@xxx.org");
$oMsg->Subject=$subject;
$oMsg->Body=$message;
$oMsg->Save();
$oMsg->Send();
?>

完整错误消息:

警告:未捕获的异常“ com_exception”,消息为“无法创建COM对象Outlook.Application”:Aufruf wurde durch Aufgerufenen abgelehnt。 '在C:\\ projekt_dreiskaen \\ mailtest.php:3中堆栈跟踪:#0 C:\\ projekt_dreiskaen \\ mailtest.php(3):com-> com('Outlook.Applica ...')#1 {main}抛出第3行的C:\\ projekt_dreiskaen \\ mailtest.php

致命错误:...中超过30秒的最大执行时间

我在大型公司Windows域中的Win 7 Enterprise上,使用我的本地管理员权限运行xampp。 大约15个用户将需要从我的应用程序发送电子邮件。

任何帮助,将不胜感激 :)

对我来说,下一个代码可以直接使用:

<?php
$subject="This is a test message";

$message="This is a Body Section now.....! :)";

$to="someaddress@somedomain.com";

// starting outlook

**com_load_typelib("outlook.application");**

if (!defined("olMailItem")) {define("olMailItem",0);}

$outlook_Obj = new COM("outlook.application") or die("Unable to start Outlook");

//just to check you are connected.

echo "Loaded MS Outlook, version {$outlook_Obj->Version}\n";

$oMsg = $outlook_Obj->CreateItem(olMailItem);

$oMsg->Recipients->Add($to);

$oMsg->Subject=$subject;

$oMsg->Body=$message;

$oMsg->Save();

$oMsg->Send();

?> 

我认为该错误( Maximum execution time of 30 seconds exceeded...)非常明显-最有可能的Outlook正在显示配置文件选择对话框,并且没有人可以关闭它。

您的代码是否在服务(例如IIS)下运行? 无法通过服务使用Outlook。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM