为什么我仍然让雅虎反弹错误?

时间:2014-09-17 16:16:04

标签: php

我使用雅虎电子邮件地址在我的表单中提交测试电子邮件并发送到Gmail地址时,我收到了yahoo bounceback错误。

我知道雅虎在使用phpmailer" FROM"时会抛出错误,但我在网上看到的内容,包括在这里,说使用" SETFROM"。电子邮件已发送,但来自空白。我怎样才能传递用户电子邮件并向他发送表格副本?我目前正在使用密送件向他发送电子邮件副本。

<?php
session_start();

include("php/simple-php-captcha/simple-php-captcha.php");
include("php/php-mailer/class.phpmailer.php");


// Step 1 - Enter your email address below.
$to = 'info@novawebdev.com';

$arrResult = array('response'=>'');

if(isset($_POST['emailSent'])) {

    $subject = 'RTO Camera Application';

    // Step 2 - If you don't want a "captcha" verification, remove that IF.
    if (strtolower($_POST["captcha"]) == strtolower($_SESSION['captcha']['code'])) {

        $first_name = $_POST['first_name'];
        $last_name = $_POST['last_name'];
        $business_name = $_POST['business_name'];
        $phone = $_POST['phone'];
        $email = $_POST['email'];
        $merchantid = $_POST['merchantid'];

        // Step 3 - Configure the fields list that you want to receive on the email.
    $fields = array(
        0 => array(
            'text' => 'First Name',
            'val' => $_POST['first_name']
        ),
        1 => array(
            'text' => 'Last Name',
            'val' => $_POST['last_name']
        ),
        2 => array(
            'text' => 'Business Name',
            'val' => $_POST['business_name']
        ),
        3 => array(
            'text' => 'Phone Number',
            'val' => $_POST['phone']
        ),
        4 => array(
            'text' => 'Email',
            'val' => $_POST['email']
        ),
        5 => array(
            'text' => 'Merchant ID',
            'val' => $_POST['merchantid']
        )
    );

    $message = "";

    // foreach($fields as $field) {
        // $message .= $field['text'].": " . htmlspecialchars($field['val'], ENT_QUOTES) . "<br>\n";
    // }

$mail = new PHPMailer;

    $mail->IsSMTP();

    // Step 4 - If you don't receive the email, try to configure the parameters below:

    //$mail->Host = 'mail.yourserver.com';                // Specify main and backup server
    //$mail->SMTPAuth = true;                             // Enable SMTP authentication
    //$mail->Username = 'username';                       // SMTP username
    //$mail->Password = 'secret';                         // SMTP password
    //$mail->SMTPSecure = 'tls';                          // Enable encryption, 'ssl' also accepted

    $mail->SetFrom($email, $first_name, $last_name);
    $mail->FromName = $_POST['first_name'].' '.$_POST['last_name'];
    $mail->AddAddress($to);
    $mail->AddReplyTo($email, $first_name, $last_name);
    $mail->AddBCC($email);
    $mail->IsHTML(true);

    $mail->CharSet = 'UTF-8';

    $mail->Subject = $subject;
    $mail->Body    = $message;  

    if($mail->Send()) {
       $arrResult['response'] = 'success';
    } else {
        $arrResult['response'] = 'error';
    }

} else {

    $arrResult['response'] = 'captchaError';

    }
}
?>

0 个答案:

没有答案