douhui8163 2019-06-26 09:34
浏览 42

Gmail收到的邮件,但其他人提供商PHPMailer没有

I'm implementing an auto email sender, Actually when I try to send my email automatically to a Gmail account, the mail is received, however when i try to send the same email to another mail domain (ex. @bouygues-construction.com), the PHP script say the email has been send but nothing is received... I'm using ionos (1&1) server mail :

    $data = file_get_contents("php://input");
    $dataAsJson = json_decode($data);
    $mail = new PHPMailer(true);
    try{
      $mail->IsSMTP();
      $mail->Mailer = "mail";
      $mail->SMTPAuth = true;
      $mail->Host = "smtp.ionos.fr";
      $mail->Port = 587; //465;
      $mail->SMTPDebug = 2;
      $mail->SMTPSecure = 'tls';
      $mail->Username = "******";
      $mail->Password = "******";
      $mail->Sender = "tpings@mydomain.fr";
      $mail->From = "tpings@mydomain.fr";
      $mail->AddAddress($dataAsJson->Email,$dataAsJson->Nom." ".$dataAsJson->Prenom);
      $mail->Subject = "Licence";
      $mail->FromName = "TPINGS Service";

      $mail->AddReplyTo('exemple@exemple.com', 'Contact TPINGS' );

      if($dataAsJson->English == true){
        $msg = "myMsg";
        $mail->AddAttachment("./uploads/Installation_EN.pdf");
      }else{
        $msg = "my_FR_msg";
        $mail->AddAttachment("./uploads/Installation_FR.pdf");
      }


      $mail->MsgHTML($msg);
      if(!$mail->Send()) {
          http_response_code(500);
          echo 'Erreur : ' . $mail->ErrorInfo;
        } else {
          http_response_code(200);
        }
    }catch(Exception $e){
      echo "Erreur mail : ".$mail->ErrorInfo;
    }

Sidenote: my spam folder is empty.

  • 写回答

1条回答 默认 最新

  • dotwc62080 2019-06-26 13:31
    关注

    You've got some confusion in here - because you're setting Mailer after calling isSMTP, it means you're not using SMTP at all, and none of your SMTP settings will be used. Remove that line and try again and you should see SMTP debug output, and probably have more success. Your current code uses mail(), so any useful debug output will be in your local mail servers's log files.

    It would only be affected by your own DNS if you were sending directly to the recipient's server. When you send through your ISP, it's their DNS that would be used.

    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)