我目前的情况是
- 我正在使用 XAMPP(本地主机)
- 所有传出端口都被阻止(Gmail 25,465,587,Hotmail等)
我想使用 PHP 连接到我自己的 Microsoft Outlook,以便我可以从我的公司电子邮件地址发送电子邮件。如果可能的话,请帮忙,谢谢!
我是否需要 Mercury Server 进行配置,因为我正在连接到 Microsoft Outlook 以发送电子邮件?
实际上,您可以直接连接到Outlook。对我来说,下一个代码开箱即用:
<?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();
?>
请确保您已添加
[COM_DOT_NET]
extension=php_com_dotnet.dll
在 php 的末尾.ini(就我而言,我有 PHP 5.3)
您没有使用 PHP 连接到 Outlook,而是连接到邮件服务器...在这种情况下,我怀疑这将是交换。您可以使用SwiftMailer,PHPMailer或Zend_Mail之类的软件包通过SMTP帐户发送消息。因此,您可以使用与 Outlook 邮箱相同的凭据和设置...具体来说:SMTP服务器(发送服务器),端口,加密(SSL/TLS)用户名,密码。
文档中的示例
- 斯威夫特邮件
- PHPMailer
- Zend_Mail