Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/238.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PhpMailer can';我似乎没有向Outlook发送邮件_Php_Phpmailer - Fatal编程技术网

PhpMailer can';我似乎没有向Outlook发送邮件

PhpMailer can';我似乎没有向Outlook发送邮件,php,phpmailer,Php,Phpmailer,我一直在尝试制作一个小型电子邮件功能,因此可以从我的网站向Outlook发送电子邮件。但是我遇到了一些问题。。 我是否必须更改我的php.ini(xampp)中的任何内容?用户名和密码应该是我的outlookusn/pass对吗? 当我运行this.php时,它说:echo“邮件未发送” 我真的看不出我做错了什么 需要'PHPMailer master/phpmailerautoad.php'; $mail=new PHPMailer(); $mail->IsSmtp(); $mail->SMT

我一直在尝试制作一个小型电子邮件功能,因此可以从我的网站向Outlook发送电子邮件。但是我遇到了一些问题。。 我是否必须更改我的
php.ini
(xampp)中的任何内容?用户名和密码应该是我的outlook
usn/pass
对吗? 当我运行this.php时,它说:
echo“邮件未发送”
我真的看不出我做错了什么

需要'PHPMailer master/phpmailerautoad.php';
$mail=new PHPMailer();
$mail->IsSmtp();
$mail->SMTPDebug=0;
$mail->SMTPAuth=true;
$mail->SMTPSecure='ssl';
$mail->Host=“smtp.office365.com”;
$mail->Port=587;//或587
$mail->IsHTML(true);
$mail->Username=”mhoegstrup@company.com";
$mail->Password=“XXXX”;
$mail->SetFrom(“mhoegstrup@company.com");
$mail->Subject=“Test”;
$mail->Body=“HEJJ”;
$mail->AddAddress(“mhoegstrup@company.com");
如果(!$mail->Send())
{
回显“未发送邮件”;
}
其他的
{
回显“已发送邮件”;
}
文件PHPMailer来自:
https://drive.google.com/file/d/0BzlVPBUP5IM8dmpDZ2tEZjdRaEU/view


谢谢你的帮助

我检查了outlook服务的文档和设置: 我意识到您只需要将SMTPSecure设置为
PHPMailer::ENCRYPTION\u STARTTLS


尝试更改$mail->SMTPSecure='ssl';到$mail->SMTPSecure=PHPMailer::ENCRYPTION\u STARTTLS<如果要调试,代码>$mail->SMTPDebug=0
不是一个好的起点;-)发送失败后不回显错误消息也没有帮助!查看PHPMailer提供的任何示例,了解如何做到这一点。您的
SMTPSecure
模式和
Port
编号组合无效-有关更多信息,请参阅PHPMailer故障排除指南。
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;