【问题标题】:PHP Email not going via hostgator webmailPHP电子邮件不通过hostgator网络邮件
【发布时间】:2018-02-08 04:41:18
【问题描述】:

我正在使用 corephp,并且我已经使用 hostgator webmail 发送电子邮件。电子邮件已成功发送到一些测试电子邮件提供商,例如 mailinator,但它不会发送到 gmail、outlook 和公司电子邮件 id。它也不在垃圾邮件/垃圾邮件中。没有记录错误信息,发送电子邮件时也不会产生任何异常。

我不明白可能是什么原因?

这是我的实际代码。

<?php
require 'PHPMailerAutoload.php';

$mail = new PHPMailer;

$mail->isMail();                                      // Set mailer to use SMTP
$mail->Host = 'http://********/webmail'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'username';                 // SMTP username
$mail->Password = 'password';                           // SMTP password
$mail->SMTPSecure = 'tls';                             // Enable encryption, 'ssl' also accepted

$mail->From = 'from@example.co';
$mail->FromName = 'Mailer';
$mail->addAddress('To@mailinator.com', 'ToUser');     // Add a recipient
$mail->addAddress('To@mailinator.com');               // Name is optional
$mail->addReplyTo('To@mailinator.com', 'Information');
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');

$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.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}

【问题讨论】:

    标签: php webmail


    【解决方案1】:

    从您的编码中删除此行

    $mail->addAddress('To@mailinator.com');   
    

    您可以使用 Gmail 帐户进行测试,您将在垃圾邮箱中收到邮件。您可以将该邮件报告为不是垃圾邮件,然后您将在 Outlook 上收到邮件。

    例如:

    $mail->addAddress('Toemailname@gmail.com', 'ToUser');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-03-03
      • 1970-01-01
      • 1970-01-01
      • 2011-11-02
      • 2011-03-21
      • 1970-01-01
      • 2011-05-21
      相关资源
      最近更新 更多