PHP没有使用Godaddy上的网站X5 evelution 9发送

时间:2017-04-21 02:26:35

标签: php smtp

我一直试图弄清楚为什么一切看起来都很完美,但是没有发送任何电子邮件。

我联系了Godaddy,他们检查了那里的所有内容,甚至从我的网站发送了一封我能够收到的电子邮件。现在我只是在处理一个基本的联系表单,但是有一个更大的项目正在制作中,并希望我的Web构建器首先处理小表单。

以下是html / Form方面的代码:

<form id="imObjectForm_8" action="mail/imEmailForm.php" method="post" enctype="multipart/form-data" style="width: 505px; margin: 0; padding: 0; text-align: left;">
    <fieldset class="first">
        <div>
            <div style="float: left; margin: 0; padding: 0 0 2px;"><label for="imObjectForm_8_1" style="vertical-align: top; display: inline-block; margin: 3px 0 2px; width: 246px;">Name*</label><br /><input type="text" class="mandatory" style="float: left; width: 220px; margin-right: 2px; vertical-align: top; padding-top: 2px; padding-bottom: 2px;" id="imObjectForm_8_1" name="imObjectForm_8_1" /><img id="imObjectForm_8_1_tip" src="res/info.gif" title="" onmouseover="x5engine.imTip.Show(this, { text: 'Enter your name here.', position: 'top' })" alt="Tip" style="vertical-align: top; margin-top: 5px;" /></div>
            <div style="float: left; margin: 0; padding: 0 0 2px;"><label for="imObjectForm_8_2" style="vertical-align: top; display: inline-block; margin: 3px 0 2px; width: 246px;">Email*</label><br /><input type="text" class="mandatory valEmail" style="float: left; width: 220px; margin-right: 2px; vertical-align: top; padding-top: 2px; padding-bottom: 2px;" id="imObjectForm_8_2" name="imObjectForm_8_2" /><img id="imObjectForm_8_2_tip" src="res/info.gif" title="" onmouseover="x5engine.imTip.Show(this, { text: 'Enter your email address here.', position: 'top' })" alt="Tip" style="vertical-align: top; margin-top: 5px;" /></div>
            <div class="imClear" style="height: 1px; line-height: 1px; width: 505px;"></div>
            <div style="float: left; margin: 0; padding: 0 0 2px;"><label for="imObjectForm_8_3" style="vertical-align: top; display: inline-block; margin: 3px 0 2px; width: 246px;">Reason for contact*</label><br /><select class="mandatory" style="float: left; width: 220px; margin-right: 2px; vertical-align: top; padding-top: 2px; padding-bottom: 2px;" id="imObjectForm_8_3" name="imObjectForm_8_3"><option value="">-</option><option value="Questions">Questions</option><option value="Comments">Comments</option><option value="Suggestions">Suggestions</option><option value="Requests">Requests</option><option value="Other">Other</option></select><img id="imObjectForm_8_3_tip" src="res/info.gif" title="" onmouseover="x5engine.imTip.Show(this, { text: 'Select the reason you are contacting us.', position: 'top' })" alt="Tip" style="vertical-align: top; margin-top: 5px;" /></div>
            <div style="float: left; margin: 0; padding: 0 0 2px;"><label for="imObjectForm_8_4" style="vertical-align: top; display: inline-block; margin: 3px 0 2px; width: 246px;">Phone #</label><br /><input type="text" class="" style="float: left; width: 220px; margin-right: 2px; vertical-align: top; padding-top: 2px; padding-bottom: 2px;" id="imObjectForm_8_4" name="imObjectForm_8_4" /><img id="imObjectForm_8_4_tip" src="res/info.gif" title="" onmouseover="x5engine.imTip.Show(this, { text: 'Phone # is optinal, but suggested if requesting we contact your back.', position: 'top' })" alt="Tip" style="vertical-align: top; margin-top: 5px;" /></div>
            <div class="imClear" style="height: 1px; line-height: 1px; width: 505px;"></div>
            <div style="float: left; margin: 0; padding: 0 0 2px;"><label for="imObjectForm_8_5" style="vertical-align: top; display: inline-block; margin: 3px 0 2px; width: 499px;">Message*</label><br /><textarea class="mandatory" style="float: left; width: 473px; margin-right: 2px; vertical-align: top; padding-top: 2px; padding-bottom: 2px; padding-left: 0; padding-right: 0; height: 130px;" id="imObjectForm_8_5" name="imObjectForm_8_5"></textarea><img id="imObjectForm_8_5_tip" src="res/info.gif" title="" onmouseover="x5engine.imTip.Show(this, { text: 'Enter your message here.', position: 'top' })" alt="Tip" style="vertical-align: top; margin-top: 5px;" /></div>
        </div>
    </fieldset>
    <fieldset>
        <input type="hidden" id="imObjectForm_8_prot" name="imSpProt" />
    </fieldset>
    <div style="width: 505px; text-align: center;">
        <input type="submit" value="Send" />
        <input type="reset" value="Reset" />
    </div>
</form>

这是PHP文件:

<?php
$settings['imEmailForm_19_8'] = array(
    "owner_email_from" => "Email",
    "owner_email_to" => "noah_swett@yahoo.com",
    "customer_email_from" => "noah_swett@yahoo.com",
    "customer_email_to" => "",
    "owner_message" => "New email from the website. message:",
    "customer_message" => "",
    "owner_subject" => "New Message",
    "customer_subject" => "",
    "owner_csv" => False,
    "customer_csv" => False,
    "confirmation_page" => "../confirmation.html"
);

if(substr(basename($_SERVER['PHP_SELF']), 0, 11) == "imEmailForm") {
    include "../res/x5engine.php";

    $answers = array(
    );

    $form_data = array(
        array('label' => 'Name', 'value' => $_POST['imObjectForm_8_1']),
        array('label' => 'Email', 'value' => $_POST['imObjectForm_8_2']),
        array('label' => 'Select', 'value' => $_POST['imObjectForm_8_3']),
        array('label' => 'Your Message', 'value' => $_POST['imObjectForm_8_4'])
    );

    $files_data = array(
    );

    if(@$_POST['action'] != "check_answer") {
        if(!isset($_POST['imJsCheck']) || $_POST['imJsCheck'] != "jsactive")
            die(imPrintJsError());
        if (isset($_POST['imCpt']) && !isset($_POST['imCptHdn']))
            die(imPrintJsError());
        if(isset($_POST['imSpProt']) && $_POST['imSpProt'] != "")
            die(imPrintJsError());
        $email = new imSendEmail();
        $email->sendFormEmail($settings['imEmailForm_19_8'], $form_data, $files_data);
        @header('Location: ' . $settings['imEmailForm_19_8']['confirmation_page']);
    } else {
        if(@$_POST['id'] == "" || @$_POST['answer'] == "" || strtolower(trim($answers[@$_POST['id']])) != strtolower(trim(@$_POST['answer'])))
            echo "0";
        else
            echo "1";
    }
}

来自imengine.php的代码

    function sendFormEmail($form, $form_data, $files_data, $user_only = FALSE) {
    global $imSettings;
    if (!is_array($form))
        $settings = $imSettings['email_form'][$form_id];
    else
        $settings = $form;
    //Form Data
    $txtData = "";
    $htmData = "";
    $csvHeader = "";
    $csvData = "";
    $customer_email_to = "";
    $owner_email_from = "";

    foreach ($form_data as $field) {
        if (is_array($field['value'])) {
            $txtData .= $field['label'] . ": " . implode(", ", $field['value']) . "\r\n";
            $htmData .= "<tr valign=\"top\"><td width=\"25%\"><b>" . $field['label'] . ":</b></td><td>" . implode(", ", $field['value']) . "</td></tr>";
            if ($settings['customer_csv'] || $settings['owner_csv']) {
                $csvHeader .= $field['label'] . ";";
                $csvData .= implode(", ", $field['value']) . ";";
            }
        } else {
            if (isset($settings['customer_email_to']) && $field['label'] == $settings['customer_email_to'])
                $customer_email_to = $field['value'];
            if (isset($settings['owner_email_from']) && $field['label'] == $settings['owner_email_from'])
                $owner_email_from = $field['value'];

            $txtData .= $field['label'] . ": " . $field['value'] . "\r\n";
            // Is it an email?
            if (preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])' . '(([a-z0-9-])*([a-z0-9]))+' . '(\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i',$field['value'])) {
                $htmData .= "<tr valign=\"top\"><td width=\"25%\"><b>" . str_replace(array("\\'", '\\"'), array("'", '"'), $field['label']) . ":</b></td><td><a href=\"mailto:" . $field['value'] . "\">". $field['value'] . "</a></td></tr>";
            } else if (preg_match('/^http[s]?:\/\/[a-zA-Z0-9\.\-]{2,}\.[a-zA-Z]{2,}/', $field['value'])) {
                // Is it an URL?
                $htmData .= "<tr valign=\"top\"><td width=\"25%\"><b>" . str_replace(array("\\'", '\\"'), array("'", '"'), $field['label']) . ":</b></td><td><a href=\"" . $field['value'] . "\">". $field['value'] . "</a></td></tr>";
            } else {
                $htmData .= "<tr valign=\"top\"><td width=\"25%\"><b>" . str_replace(array("\\'", '\\"'), array("'", '"'), $field['label']) . ":</b></td><td>" . str_replace(array("\\'", '\\"'), array("'", '"'), $field['value']) . "</td></tr>";
            }
            if ($settings['customer_csv'] || $settings['owner_csv']) {
                $csvHeader .= str_replace(array("\\'", '\\"'), array("'", '"'), $field['label']) . ";";
                $csvData .= str_replace(array("\\'", '\\"'), array("'", '"'), $field['value']) . ";";
            }
        }
    }

    // Template
    $htmHead = $imSettings['email']['header'];
    $htmFoot = $imSettings['email']['footer'];

    //Send email to owner
    if (!$user_only && isset($settings['owner_email_to']) && $settings['owner_email_to'] != "") {
        $txtMsg = $settings['owner_message'];
        $htmMsg = nl2br($settings['owner_message']);
        if (strpos($owner_email_from, "@") === FALSE || strlen($owner_email_from) == 0)
            $owner_email_from = $settings['owner_email_to'];
        $oEmail = new imEMail($owner_email_from, $settings['owner_email_to'], $settings['owner_subject'], "utf-8");
        $oEmail->setText($txtMsg . "\n\n" . $txtData);
        $oEmail->setHTML($htmHead . $htmMsg . "<br><br><table border=0 width=\"100%\" style=\"" . $imSettings['email']['email_content_style'] . "\">" . $htmData . "</table>" . $htmFoot);
        if ($settings['owner_csv'])
            $oEmail->attachFile("form_data.csv", $csvHeader . "\n" . $csvData, "text/csv");
        if (count($files_data) > 0) {
            foreach ($files_data as $file) {
                if (file_exists($file['value']['tmp_name']))
                    $oEmail->attachFile($file['value']['name'], file_get_contents($file['value']['tmp_name']), $file['value']['type']);
            }
        }
        $oEmail->send();
    }

    //Send email to user
    if ($customer_email_to != "") {
        $txtMsg = $settings['customer_message'];
        $htmMsg = nl2br($settings['customer_message']);
        if ($settings['customer_email_from'] == "")
            $settings['customer_email_from'] = $settings['owner_email_to'];
        $oEmail = new imEMail($settings['customer_email_from'], $customer_email_to, $settings['customer_subject'], "utf-8");
        if ($settings['customer_csv']) {
            $oEmail->setHTML($htmHead . $htmMsg . "<br><br><table border=0 width=\"100%\" style=\"" . $imSettings['email']['email_content_style'] . "\">" . $htmData . "</table>" . $htmFoot);
            $oEmail->setText($txtMsg . "\n\n" . $txtData);
        } else {
            $oEmail->setText($txtMsg);
            $oEmail->setHTML($htmHead . $htmMsg . $htmFoot);
        }
        $oEmail->send();
    }
}

请帮忙!

0 个答案:

没有答案