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

时间:2017-01-24 13:00:30

标签: php html ajax email phpmailer

我收到了一封发送邮件的邮件(因为$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>

我的ajax脚本:

$('#contact-form').submit(function(){

     var $form = $(this),
     $error = $form.find('.error-container'),
     action  = $form.attr('action');

     $error.slideUp(750, function() {
     $error.hide();

      var $name = $form.find('.form-control-name'),
        $email = $form.find('.form-control-email'),
        $phone = $form.find('.form-control-phone'),
        $message = $form.find('.form-control-message');

     $.post(action, {
             name: $name.val(),
             email: $email.val(),
             phone: $phone.val(),
             message: $message.val()
        },
        function(data){
             $error.html(data);
             $error.slideDown('slow');

             if (data.match('success') != null) {
                $name.val('');
                $email.val('');
                $phone.val('');
                $message.val('');
             }
        }
     );
});

我的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;

1 个答案:

答案 0 :(得分:1)

如果您不使用SMTP发送邮件,则可能是服务器配置或电子邮件可能被退回,因为websiteshairdesign.nl不是注册域。

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

所以试试: - 使用现有域从服务器上的现有电子邮件地址发送电子邮件 - 到Gmail或Hotmail地址以阻止本地投放。

希望这有帮助。