无法将邮件发送到电子邮件服务器

时间:2015-06-19 14:30:23

标签: smtp phpmailer

我正在使用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";
     ?>

1 个答案:

答案 0 :(得分:0)

您应该更新您正在使用的PHPMailer版本,此代码适用于旧版本,尝试浏览他们的Github page,他们在那里有很多示例。