我开发了一个需要向用户发送电子邮件的PHP系统。发件人使用的是Outlook帐户,电子邮件收件人也是如此。我正在使用PHPmailer发送电子邮件。
仅供参考,我的SMTP是有效的,因为我是从我公司的IT部门获得的。
这是我在php.ini中更改的内容:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = abc-smtp.mycompany.local
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = abc@mycompany.com
当我运行代码时,我收到了3个错误:
Warning: fsockopen() [<a href='function.fsockopen'>function.fsockopen</a>]: Failed to
enable crypto in C:\wamp\www\assetmanagementsystem\class.smtp.php on line 122
Warning: fsockopen() [<a href='function.fsockopen'>function.fsockopen</a>]: unable to
connect to tls://abc-smtp.mycompany.local:25 (Unknown error) in
C:\wamp\www\assetmanagementsystem\class.smtp.php on line 122
Warning: fsockopen() [<a href='function.fsockopen'>function.fsockopen</a>]: SSL: crypto
enabling timeout in C:\wamp\www\assetmanagementsystem\class.smtp.php on line 122
它还说PHPMailer错误:SMTP错误:无法连接到SMTP主机。
这是我对电子邮件的编码:
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host = 'abc-smtp.mycompany.local';
$mail->Port = 25;
$mail->From = "assi@mycompany.com";
$mail->FromName = "Asset Management System";
$mail->Subject = "Notification on less of stock";
$mail->MsgHTML($message);
$mail->AddAddress("assi@mycompany.com","Asset Management System");
$mail->IsHTML(true);
if(!$mail->Send())
echo "Message was not sent <br />PHPMailer Error: " . $mail->ErrorInfo;
else
echo "Message has been sent";
仅仅为了补充,我在PHP.ini中启用了我的OpenSSL。有人可以帮我吗 ?为什么我有这个错误以及如何克服它。我真的需要解决这个问题。提前致谢。