I'm getting yahoo bounceback errors when submitting a test email in my form using a yahoo email address and sending to a gmail address.
I know that yahoo throws errors when using the phpmailer "FROM", but what I've read online, including here, says to use "SETFROM". The email is sent, but the from is blank. How can I still pass in the users email and send him a copy of the form? I'm currently using a bcc to send him a copy of the email.
<?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>
";
// }
$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';
}
}
?>