【问题标题】:mail send message display but mail is not coming [duplicate]邮件发送消息显示但邮件不来[重复]
【发布时间】:2020-06-03 06:45:35
【问题描述】:

我有 sendnewmail 功能使用它发送邮件,在邮件消息中发送消息显示但在 gmail 中它不来,这是代码

function sendnewmail($msgnew,$emailidnew,$subjectnew){
   require_once("class.phpmailer.php");
      require_once("class.smtp.php");
         $mail = new PHPMailer();
      $mail->IsSMTP();     // set mailer to use SMTP
      $mail->Host = "mail.domain.com"; // specify main and backup server
      $mail->SMTPAuth = true;     // turn on SMTP authentication
      $mail->Username ="user";  // SMTP username
      $mail->Password ="password"; // SMTP password
      $mail->From = "abcds@gmail.com";
      $mail->FromName = "name";
      $mail->AddAddress($emailidnew,"sudeshna");
      $mail->WordWrap = 50;                                 // set word wrap to 50 characters
      $mail->IsHTML(true);                                  // set email format to HTML
          $mail->Subject = $subjectnew;
      $mail->Body    = $msgnew;
          if(!$mail->Send())      {
        echo "Message could not be sent. <p>";
         echo "Mailer Error: " . $mail->ErrorInfo;
         exit;
  }else{
          echo 'Message send ok';
      }
}
$htmldetails ="Welcome to World";
$email = "abc@gmail.com";
$subject = "Sample welcome message";
sendnewmail($htmldetails,$email,$subject);



【问题讨论】:

  • 在 gmail 中它不来 你是否使用 gmail 作为 smtp 服务器?话虽这么说,为了测试,最好使用本地服务器(例如fakesmtp),这样您就可以确定应用程序实际上首先发送电子邮件,然后您可以担心 smtp 服务器稍后丢弃您的邮件(由于原因,例如垃圾邮件)。 .
  • 邮件发送到 gmail (abc@gmail.com) 账户
  • 您使用的是旧版本的 PHPMailer。 Get the latest。如果您通过 gmail 发送,请将您的代码基于the gmail example provided,并阅读the troubleshooting guide

标签: php email smtp phpmailer


【解决方案1】:

希望这项工作

  function sendnewmail($msgnew,$emailidnew,$subjectnew){
  require_once("PHPMailer/class.phpmailer.php");
  require_once("PHPMailer/class.smtp.php");
  $mail = new PHPMailer();
  $mail->isSMTP();
  $mail->Host = "mail.domain.com"; // specify main and backup server
  $mail->Port = 465;

  $mail->SMTPSecure = 'ssl';

  $mail->SMTPAuth = true;
  $mail->Username ="user";  // SMTP username
  $mail->Password ="password"; // SMTP password
  $mail->From = "abc@domain.com";
  $mail->FromName = "name";
  $mail->AddAddress($emailidnew,"sudeshna");
  $mail->WordWrap = 50;                         
  $mail->IsHTML(true);                       
      $mail->Subject = $subjectnew;
  $mail->Body    = $msgnew;
      if(!$mail->Send())      {
    echo "Message could not be sent. <p>";
     echo "Mailer Error: " . $mail->ErrorInfo;
     exit;
  }else{
      echo 'Message send ok';
  }
 }
 $htmldetails ="Welcome to World";
 $email = "tausifahmad810@gmail.com";
 $subject = "Sample welcome message";
 sendnewmail($htmldetails,$email,$subject);

【讨论】:

  • 我检查过,但也没有在垃圾邮件中
猜你喜欢
  • 2020-05-03
  • 2017-05-29
  • 1970-01-01
  • 2015-07-05
  • 2016-09-07
  • 1970-01-01
  • 2021-11-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多