简体   繁体   English

PHPMailer在发送邮件时遇到问题

[英]PHPMailer having problems with sending mail

I have placed the code of the PHPMailer in the file where I want to sent the mail but the mail is not delivered. 我已经将PHPMailer的代码放置在要发送邮件的文件中,但是邮件未送达。 I tried the ordinary mail() method but both sends the message but the message is not delivered. 我尝试了普通的mail()方法,但是都发送了消息,但是消息未传递。 Can this be the issue with host service?? 这可能是主机服务的问题吗?

  include('PHPMailer-master/PHPMailerAutoload.php');
  $mail = new PHPMailer;
  // Set PHPMailer to use the sendmail transport
   $mail->isSendmail();
  //Set who the message is to be sent from
  $mail->setFrom('from@example.com', 'First Last');
  //Set an alternative reply-to address
   $mail->addReplyTo('replyto@example.com', 'First Last');
  //Set who the message is to be sent to
  $mail->addAddress( $_POST['RequestedEmail'], 'John Doe');
  //Set the subject line
  $mail->Subject = 'PHPMailer sendmail test';
  //Read an HTML message body from an external file, convert referenced  images to embedded,
 //convert HTML into a basic plain-text alternative body
 $mail->msgHTML("");
 //Replace the plain text body with one created manually
 $mail->AltBody = 'This is a plain-text message body';
  //send the message, check for errors
  if (!$mail->send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
  } else {
  echo "Message sent!";
}

Note: New to php 注意:php新手

I tried both the mail() native function of the php and phpmailer. 我尝试了php和phpmailer的mail()本机功能。 Both said that mail was sent and successful message appeared but the message was not delivered. 双方都说已发送邮件,并显示成功消息,但未传递该消息。 I asked the technicians on the hosting server and they replied that spam blocker has blocked the messages. 我问托管服务器上的技术人员,他们回答说垃圾邮件阻止程序已阻止了邮件。 So they are asking for the contents and headers of the messages to confirm it was clear and to unblock the it from spamer. 因此,他们要求提供消息的内容和标头,以确认消息是否清晰并阻止垃圾邮件发送者。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM