Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 邮件已发送,但从未到达任何地方_Php_Html_Ajax_Email_Phpmailer - Fatal编程技术网

Php 邮件已发送,但从未到达任何地方

Php 邮件已发送,但从未到达任何地方,php,html,ajax,email,phpmailer,Php,Html,Ajax,Email,Phpmailer,我得到了一个发送邮件的mailscript(因为$mail->send()返回true),我还得到了看起来都不错的标题。没有显示任何错误,所以我假设一切正常,但不知何故,我的邮件从未到达任何地方。不在gmail上,也不在outlook上。可能是什么问题?我已经从同一服务器上的另一个域发送了一些测试邮件,效果很好 我发送的域名是全新的,所以我怀疑它被列入黑名单或类似的东西 我的html表单: <form id="contact-form" class="contact-form" metho

我得到了一个发送邮件的mailscript(因为
$mail->send()
返回true),我还得到了看起来都不错的标题。没有显示任何错误,所以我假设一切正常,但不知何故,我的邮件从未到达任何地方。不在gmail上,也不在outlook上。可能是什么问题?我已经从同一服务器上的另一个域发送了一些测试邮件,效果很好

我发送的域名是全新的,所以我怀疑它被列入黑名单或类似的东西

我的html表单:

<form id="contact-form" class="contact-form" method="post" action="mail/mail_send.php" role="form">
    <div class="error-container"></div>
    <input type="text" placeholder="Naam *" class="name form-control-name" name="name" required>
    <input type="email" placeholder="E-mail *" class="email form-control-email" name="email" required>
    <input style="width:100%;" type="text" placeholder="Telefoonnummer" class="phone form-control-phone" name="phone">
    <textarea name="message" placeholder="Bericht *" class="message form-control-message" rows="8" cols="20" required></textarea>
    <input type="submit" name="submit" value="Verzenden">
</form>
我的PHP邮件脚本:

<?PHP
require_once("../phpMailer/class.phpmailer.php");
$isValid = true;
if(isset($_POST['name']) && isset($_POST['mail']) && isset($_POST['phone']) && isset($_POST['message']))
{
    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $message = $_POST['message'];
    $subject = 'Er is een aanvraag op de website van website\'s Hairdesign';
    $mail = new PHPMailer;
    $mail->From = $email;
    $mail->FromName = $name;
    $mail->addAddress("my-email@outlook.com");
    $mail->isHTML(true);
    $mail->Subject = $subject;
    $texts = 'Er is een aanvraag op de website van website\'s Hairdesign<br /> <br />
    <b>Naam:</b> '.$name.'<br />
    <b>E-mail adres:</b> '.$email.'<br />
    <b>Telefoonnummer:</b> '.$phone.'<br />
    <b>Bericht:</b> '.$message.'<br /><br /><br />
    ';

    $handtekening = '
    <table border="0" width="100%" cellspacing="0" cellpadding="0" style="font-family:calibri;color: #5C5C5C; font-size:10pt;line-height:22px;">
    <tr>
    <td width="160" valign="top" style="font-family:calibri;padding-left:10px;padding-top:20px;">
    [contents]
    </td>
    </tr>
    <tr>
    <td width="160" valign="top" style="font-family:calibri;padding-left:10px;padding-top:20px;">
    Helpdesk<br>
    <b>website\'s Hairdesign</b><br>
    <p></p>
    </td>
    </tr>
    </table>
    <table height="120" border="0" width="100%" cellspacing="0" cellpadding="0" style="font-family:calibri;color: #5C5C5C; font-size:10pt;line-height:22px;">
    <tr>
    <td width="250" valign="top" style="font-family:calibri;padding-left:10px;padding-top:20px;border-top: 1px #000000 dotted; border-bottom: 1px #000000 dotted;">
    E:&nbsp;&nbsp;
    <a href="mailto:info@websiteshairdesign.nl" style="font-family:calibri;color: #5C5C5C; text-decoration: none; border-bottom: 1px #5C5C5C dotted;">info@websiteshairdesign.nl</a><br>
    T:&nbsp;&nbsp;
    <a href="tel:+310181506451" style="font-family:calibri;color: #5C5C5C; text-decoration: none; border-bottom: 1px #5C5C5C dotted;">+31-(0)181-506451</a><br>
    W:&nbsp;
    <a href="http://websiteshairdesign.nl/" style="font-family:calibri;color: #5C5C5C; text-decoration: none; border-bottom: 1px #5C5C5C dotted;" target="_blank">www.podlogistics.nl</a><br>
    </td>
    <td align="right" style="font-family:calibri;padding-right:10px;padding-top:5px;border-top: 1px #000000 dotted; border-bottom: 1px #000000 dotted;">
    <a href="http://websiteshairdesign.nl/" target="_blank" title="Ga naar de website">
    <img src="http://websitemedia.nl/_extern/websites/img/logo-websites.png" alt="Ga naar de website" style="font-family:calibri;text-align:right;margin:0px;padding:10px 0 10px 0;" border="0" width="232">
    </a>
    </td>
    </tr>
    <tr>
    <td colspan="2" style="font-family:calibri;color:#a3a3a3;font-size:11px;margin-top:6px;line-height:14px;">
    <br>Dit e-mailbericht is uitsluitend bestemd voor de geadresseerde. Als dit bericht niet voor u bestemd is, wordt u vriendelijk verzocht dit aan de afzender te melden. website\'s Hairdesign staat door de elektronische verzending van dit bericht niet in voor de juiste en volledige overbrenging van de inhoud, noch voor tijdige ontvangst daarvan. Voor informatie over website\'s Hairdesign raadpleegt u <a href="http://websiteshairdesign.nl/" style="font-family:calibri;color: #5C5C5C; text-decoration: none; border-bottom: 1px #5C5C5C dotted;" target="_BLANK">website\'s Hairdesign</a>.<br><br>
    </td>
    </tr>
    </table>';


    $contents = preg_replace('/\[contents]/',$texts, $handtekening);
    $mail->msgHTML($contents);
    $mail->AltBody = $texts;
    if(!$mail->send())
    {
        $isValid = false;
    }

    $mail = new PHPMailer;
    $mail->From = 'info@websiteshairdesign.nl';
    $mail->FromName = 'website\'s Hairdesign';
    $mail->addAddress($email);     
    $mail->isHTML(true);           
    $mail->Subject = 'Bedankt voor uw aanvraag bij website\'s Hairdesign';
    $texts = 'Geachte heer/mevrouw '.$naam.',<br /><br />
    Hartelijk dank voor uw aanvraag, wij zullen hier zo spoedig mogelijk op reageren.<br />
    <br>
    Met vriendelijke groet,
    ';
    $contents = preg_replace('/\[contents]/',$texts, $handtekening);
    $mail->msgHTML($contents);
    $mail->AltBody = $texts;
    if(!$mail->send())
        $isValid = false;
    }
    if($isValid == true) {
        $result = 'Bedankt voor uw aanvraag! Wij nemen z.s.m. contact met u op.';
    } else {
        $result = 'Vul alle velden in!';
    }

    echo $result;

如果您没有使用SMTP发送邮件,可能是服务器配置问题,也可能是由于websiteshairdesign.nl不是注册域而导致电子邮件被退回

检查服务器上的邮件日志以检查电子邮件是否成功发送。使用服务器上现有的电子邮件地址,检查是否允许发送邮件(SPF记录)。此外,如果您使用的是外部邮件托管,并且您发送到的电子邮件地址的域在服务器上也是已知的,则电子邮件可能会在本地传递,而不是发送到外部服务器

因此,请尝试: -使用现有域从服务器上的现有电子邮件地址发送电子邮件 -发送到Gmail或Hotmail地址以阻止本地传递


希望这能有所帮助。

您的本地邮件服务器日志怎么说?(通常在
/var/log/mail.log
)@Synchro我在我的服务器上找不到它们。我有一个邮件文件夹,但它只包含来自此域的所有邮件地址,而不包含日志。我建议您切换到使用SMTP到本地主机:包括SMTP类,调用
$mail->isSMTP(),设置
$mail->Host='localhost'。它应该以同样的方式工作,但这意味着您可以在提交过程中获得更多反馈(设置
$mail->SMTPDebug=2
)。我在哪里可以找到更详细的反馈?它仍然像以前一样发送电子邮件。这应该是非常明显的-它在发送呼叫期间大量输出调试信息。我不知道在哪里可以找到邮件日志。我也没有使用外部邮件托管。你认为当域名还不存在时邮件会被退回吗?我以前多次这样做都没有问题。这取决于你使用的垃圾邮件过滤器。如果允许服务器发送电子邮件(SPF)等,大多数垃圾邮件过滤器会检查域是否存在。你在哪里托管,你在VPS上吗?我从本地服务器发送,域托管在它上面。我不在VPS上。因为您使用的是本地服务器,所以可能没有设置反向DNS,这可能是垃圾邮件过滤器在不通知您的情况下完全弹出电子邮件的原因。尝试使用SMTP发送电子邮件。这也更可靠。
<?PHP
require_once("../phpMailer/class.phpmailer.php");
$isValid = true;
if(isset($_POST['name']) && isset($_POST['mail']) && isset($_POST['phone']) && isset($_POST['message']))
{
    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $message = $_POST['message'];
    $subject = 'Er is een aanvraag op de website van website\'s Hairdesign';
    $mail = new PHPMailer;
    $mail->From = $email;
    $mail->FromName = $name;
    $mail->addAddress("my-email@outlook.com");
    $mail->isHTML(true);
    $mail->Subject = $subject;
    $texts = 'Er is een aanvraag op de website van website\'s Hairdesign<br /> <br />
    <b>Naam:</b> '.$name.'<br />
    <b>E-mail adres:</b> '.$email.'<br />
    <b>Telefoonnummer:</b> '.$phone.'<br />
    <b>Bericht:</b> '.$message.'<br /><br /><br />
    ';

    $handtekening = '
    <table border="0" width="100%" cellspacing="0" cellpadding="0" style="font-family:calibri;color: #5C5C5C; font-size:10pt;line-height:22px;">
    <tr>
    <td width="160" valign="top" style="font-family:calibri;padding-left:10px;padding-top:20px;">
    [contents]
    </td>
    </tr>
    <tr>
    <td width="160" valign="top" style="font-family:calibri;padding-left:10px;padding-top:20px;">
    Helpdesk<br>
    <b>website\'s Hairdesign</b><br>
    <p></p>
    </td>
    </tr>
    </table>
    <table height="120" border="0" width="100%" cellspacing="0" cellpadding="0" style="font-family:calibri;color: #5C5C5C; font-size:10pt;line-height:22px;">
    <tr>
    <td width="250" valign="top" style="font-family:calibri;padding-left:10px;padding-top:20px;border-top: 1px #000000 dotted; border-bottom: 1px #000000 dotted;">
    E:&nbsp;&nbsp;
    <a href="mailto:info@websiteshairdesign.nl" style="font-family:calibri;color: #5C5C5C; text-decoration: none; border-bottom: 1px #5C5C5C dotted;">info@websiteshairdesign.nl</a><br>
    T:&nbsp;&nbsp;
    <a href="tel:+310181506451" style="font-family:calibri;color: #5C5C5C; text-decoration: none; border-bottom: 1px #5C5C5C dotted;">+31-(0)181-506451</a><br>
    W:&nbsp;
    <a href="http://websiteshairdesign.nl/" style="font-family:calibri;color: #5C5C5C; text-decoration: none; border-bottom: 1px #5C5C5C dotted;" target="_blank">www.podlogistics.nl</a><br>
    </td>
    <td align="right" style="font-family:calibri;padding-right:10px;padding-top:5px;border-top: 1px #000000 dotted; border-bottom: 1px #000000 dotted;">
    <a href="http://websiteshairdesign.nl/" target="_blank" title="Ga naar de website">
    <img src="http://websitemedia.nl/_extern/websites/img/logo-websites.png" alt="Ga naar de website" style="font-family:calibri;text-align:right;margin:0px;padding:10px 0 10px 0;" border="0" width="232">
    </a>
    </td>
    </tr>
    <tr>
    <td colspan="2" style="font-family:calibri;color:#a3a3a3;font-size:11px;margin-top:6px;line-height:14px;">
    <br>Dit e-mailbericht is uitsluitend bestemd voor de geadresseerde. Als dit bericht niet voor u bestemd is, wordt u vriendelijk verzocht dit aan de afzender te melden. website\'s Hairdesign staat door de elektronische verzending van dit bericht niet in voor de juiste en volledige overbrenging van de inhoud, noch voor tijdige ontvangst daarvan. Voor informatie over website\'s Hairdesign raadpleegt u <a href="http://websiteshairdesign.nl/" style="font-family:calibri;color: #5C5C5C; text-decoration: none; border-bottom: 1px #5C5C5C dotted;" target="_BLANK">website\'s Hairdesign</a>.<br><br>
    </td>
    </tr>
    </table>';


    $contents = preg_replace('/\[contents]/',$texts, $handtekening);
    $mail->msgHTML($contents);
    $mail->AltBody = $texts;
    if(!$mail->send())
    {
        $isValid = false;
    }

    $mail = new PHPMailer;
    $mail->From = 'info@websiteshairdesign.nl';
    $mail->FromName = 'website\'s Hairdesign';
    $mail->addAddress($email);     
    $mail->isHTML(true);           
    $mail->Subject = 'Bedankt voor uw aanvraag bij website\'s Hairdesign';
    $texts = 'Geachte heer/mevrouw '.$naam.',<br /><br />
    Hartelijk dank voor uw aanvraag, wij zullen hier zo spoedig mogelijk op reageren.<br />
    <br>
    Met vriendelijke groet,
    ';
    $contents = preg_replace('/\[contents]/',$texts, $handtekening);
    $mail->msgHTML($contents);
    $mail->AltBody = $texts;
    if(!$mail->send())
        $isValid = false;
    }
    if($isValid == true) {
        $result = 'Bedankt voor uw aanvraag! Wij nemen z.s.m. contact met u op.';
    } else {
        $result = 'Vul alle velden in!';
    }

    echo $result;