【发布时间】:2015-09-05 14:07:55
【问题描述】:
我正在使用 PHPMailer 库通过我的邮件服务器发送电子邮件,域名为 pixel.com。我可以将电子邮件发送到所有电子邮件地址,例如 Gmail、雅虎等,但我无法将邮件发送到以下电子邮件地址属于同一个服务器,如 admin@pixels.com。有人可以建议我解决这个问题吗。我需要更改一些设置吗。解决这个问题的其他可能解决方案是什么。我用于发送邮件的 php 代码是
<?php
require("class.PHPMailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "smtp1.example.com;smtp2.example.com"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "jswan"; // SMTP username
$mail->Password = "secret"; // SMTP password
$mail->From = "from@example.com";
$mail->FromName = "Mailer";
$mail->AddAddress("josh@example.net", "Josh Adams");
$mail->AddAddress("ellen@example.com"); // name is optional
$mail->AddReplyTo("info@example.com", "Information");
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments
$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = "Here is the subject";
$mail->Body = "This is the HTML message body <b>in bold!</b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
【问题讨论】:
-
如果您能够发送到其他电子邮件地址,那么听起来代码正在按设计工作。也许您需要询问您的托管服务提供商为什么他们的电子邮件会丢失?
-
我想知道我们是否可以使用程序将邮件从一台服务器发送到属于同一台服务器的电子邮件地址
-
这不是工作代码。您使用的是旧示例和旧版本的 PHPMailer。
-
请帮我获取新代码