即使在POST成功后也没有收到邮件

时间:2015-11-18 14:00:49

标签: php email

我收到了一份有效的mailscript,我之前测试过它。

现在突然使用相同的代码我没有收到任何邮件,也没有其他人收到邮件。

我在outlook和gmail上查看了垃圾邮件和收件箱。

这是我的邮件脚本:

<?PHP
require_once ('config.php');
require_once("../phpMailer/class.phpmailer.php");
$isValid = true;
if(isset($_POST['name']) && isset($_POST['subject']) && isset($_POST['email']) && isset($_POST['message'])) 
{
    $name = $_POST['name'];
    $subject = 'Er is een contact aanvraag op Kijk & Zie : '.$_POST['subject'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    $phone = $_POST['phone'];
    $mail = new PHPMailer;
    $mail->From = $email;
    $mail->FromName = $name;
    $mail->addAddress("receiver@live.nl");   // Add a recipient
    $mail->isHTML(true);                      // Set email format to HTML
    $mail->Subject = $subject;
    $texts = 'Er is een aanvraag op de website van Kijk & Zie<br /> <br />
    <b>Naam:</b> '.$name.'<br />
    <b>E-mail adres:</b> '.$email.'<br />
    <b>Onderwerp:</b> '.$subject.'<br />
    <b>Telefoonnummer:</b>'.$phone.'<br />
    <b>Vragen / Opmerkingen:</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;">
    <br><br>Met vriendelijke groet,<br><br>
    Helpdesk<br>
    <b>Kijk & Zie</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@website.nl" style="font-family:calibri;color: #5C5C5C; text-decoration: none; border-bottom: 1px #5C5C5C dotted;">info@website.nl</a><br>
    T:&nbsp;&nbsp;
    <a href="tel:0181851859" style="font-family:calibri;color: #5C5C5C; text-decoration: none; border-bottom: 1px #5C5C5C dotted;">(0181) 851 859</a><br>
    W:&nbsp;&nbsp;
    <a href="http://website.nl" style="font-family:calibri;color: #5C5C5C; text-decoration: none; border-bottom: 1px #5C5C5C dotted;" target="_blank">www.website.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://website.nl/" target="_blank" title="Ga naar de website">
    <img src="http://www.website-kindercoaching.nl" 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. Kijk & Zie 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 Kijk & Zie raadpleegt u <a href="http://website-kindercoaching.nl" style="font-family:calibri;color: #5C5C5C; text-decoration: none; border-bottom: 1px #5C5C5C dotted;" target="_BLANK">Kijk & Zie</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@website.nl';
    $mail->FromName = 'Kijk & Zie';
    $mail->addAddress($email);     // Add a recipient
    $mail->isHTML(true);           // Set email format to HTML
    $mail->Subject = 'Bedankt voor uw aanvraag bij Kijk & Zie';
    $texts = 'Geachte heer/mevrouw '.$naam.',<br /><br />
    Hartelijk dank voor uw aanvraag bij Kijk & Zie<br />
    Wij reageren zo spoedig mogelijk op uw aanvraag.<br /><br />
    Uw gegevens worden nooit aan derden ter hand gesteld.
    ';
    $contents = preg_replace('/\[contents]/',$texts, $handtekening);
    $mail->msgHTML($contents);
    $mail->AltBody = $texts;
    if(!$mail->send()) 
        $isValid = false;
    }
    if($isValid == true) {
        $result["submit_message"] = _msg_send_ok;
    } else {
        $result["submit_message"] = _msg_send_error;
    }

    $array = array(
    'isValid' => $isValid
    );

    echo json_encode($result);

如果有人需要,这是ajax代码:

//contact form
    if($(".contact-form").length)
    {
        $(".contact-form").each(function(){
            $(this)[0].reset();
        });
        $(".submit-contact-form").on("click", function(event){
            event.preventDefault();
            $("#contact-form").submit();
        });
    }
    $(".contact-form").submit(function(event){
        event.preventDefault();
        var data = $(this).serializeArray();
        var self = $(this);
        //if($(this).find(".total-cost").length)
        //  data.push({name: 'total-cost', value: $(this).find(".total-cost").val()});
        self.find(".block").block({
            message: false,
            overlayCSS: {
                opacity:'0.3',
                "backgroundColor": "#FFF"
            }
        });

        $.ajax({
            url: self.attr("action"),
            data: data,
            type: "post",
            dataType: "json",
            success: function(json){
                self.find(".submit-contact-form, [name='submit'], [name='name'], [name='email'], [name='message']").qtip('destroy');
                if(typeof(json.isOk)!="undefined" && json.isOk)
                {
                    if(typeof(json.submit_message)!="undefined" && json.submit_message!="")
                    {
                        self.find(".submit-contact-form").qtip(
                        {
                            style: {
                                classes: 'ui-tooltip-success'
                            },
                            content: { 
                                text: json.submit_message 
                            },
                            position: { 
                                my: "right center",
                                at: "left center" 
                            }
                        }).qtip('show');
                        self[0].reset();
                        self.find(".cost-slider-input").trigger("change");
                        self.find(".cost-dropdown").selectmenu("refresh");
                        self.find("input[type='text'], textarea").trigger("focus").trigger("blur");
                    }
                }
                else
                {
                    if(typeof(json.submit_message)!="undefined" && json.submit_message!="")
                    {
                        self.find(".submit-contact-form").qtip(
                        {
                            style: {
                                classes: 'ui-tooltip-error'
                            },
                            content: { 
                                text: json.submit_message 
                            },
                            position: { 
                                my: "right center",
                                at: "left center" 
                            }
                        }).qtip('show');
                    }
                    if(typeof(json.error_name)!="undefined" && json.error_name!="")
                    {
                        self.find("[name='name']").qtip(
                        {
                            style: {
                                classes: 'ui-tooltip-error'
                            },
                            content: { 
                                text: json.error_name 
                            },
                            position: { 
                                my: "bottom center",
                                at: "top center" 
                            }
                        }).qtip('show');
                    }
                    if(typeof(json.error_email)!="undefined" && json.error_email!="")
                    {
                        self.find("[name='email']").qtip(
                        {
                            style: {
                                classes: 'ui-tooltip-error'
                            },
                            content: { 
                                text: json.error_email 
                            },
                            position: { 
                                my: "bottom center",
                                at: "top center" 
                            }
                        }).qtip('show');
                    }
                    if(typeof(json.error_message)!="undefined" && json.error_message!="")
                    {
                        self.find("[name='message']").qtip(
                        {
                            style: {
                                classes: 'ui-tooltip-error'
                            },
                            content: { 
                                text: json.error_message 
                            },
                            position: { 
                                my: "bottom center",
                                at: "top center" 
                            }
                        }).qtip('show');
                    }
                }
                self.find(".block").unblock();
            }
        });
    });

是什么阻止我接收/发送任何电子邮件?

当我提交表单时,它会给我一条成功消息,而在serverlog中,我可以看到它已成功发布。

0 个答案:

没有答案
相关问题