【发布时间】:2018-10-16 20:44:38
【问题描述】:
我附上了两个不同的 PDF 文件(mnlocalXampp 和 rnlocalXampp),它们是两台不同电脑的 phpinfo。我检查了这两个信息,似乎两者都有相同的信息并使用相同版本的 PHP,但我在 mnlocalXampp 中收到电子邮件,但在 rnlocalXampp 中没有。我还在两者中都激活了 openssl,但我仍然没有在 rnlocalxampp 中收到电子邮件。任何人都可以看看这两个文件,让我知道这些文件有什么区别以及如何配置。
<?php
require 'email_class/class.phpmailer.php';
$mail = new PHPMailer;
$mail->IsSMTP(); //Sets Mailer to send message using SMTP
$mail->Host = 'cp-in-10.webhostbox.net'; //Sets the SMTP hosts of your Email hosting, this for Godaddy
$mail->Port = '465'; //Sets the default SMTP server port
$mail->SMTPAuth = true; //Sets SMTP authentication. Utilizes the Username and Password variables
$mail->Username = 'mn@infotech.com'; //Sets SMTP username
$mail->Password = 'xxxxxxx'; //Sets SMTP password
$mail->SMTPSecure = 'ssl'; //Sets connection prefix. Options are "", "ssl" or "tls"
$mail->From = 'mn@infotech.com'; //Sets the From email address for the message
$mail->FromName = "mn"; //Sets the From name of the message
$mail->AddAddress("m@infotech.com"); //Adds a "To" address
$mail->AddCC("m@infotech.com"); //Adds a "Cc" address
$mail->WordWrap = 50; //Sets word wrapping on the body of the message to a given number of characters
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$mail->IsHTML(true); //Sets message type to HTML
$mail->Subject = 'Project CMS'; //Sets the Subject of the message
$mail->Body = $message; //An HTML or plain text message body
$mail->AddStringAttachment($doc, 'doc.pdf', 'base64', 'application/pdf');
$mail->Send(); ?>
以上示例代码是mnlocaXampp的邮件配置。对于 rnlocalXampp,我使用不同的端口(端口号:25)、托管、启用 SSL。
提前致谢
【问题讨论】: