I have set up SMTL like this,
add_action( "phpmailer_init", "send_smtp_email" );
function send_smtp_email( $phpmailer ) {
ini_set("sendmail_from","[email protected]");
ini_set("sendmail_path","[email protected]");
// Define that we are sending with SMTP
$phpmailer->isSMTP();
// The hostname of the mail server
$phpmailer->Host = "localhost";
// Use SMTP authentication (true|false)
$phpmailer->SMTPAuth = false;
// SMTP port number - likely to be 25, 465 or 587
$phpmailer->Port = "25";
// Encryption system to use - ssl or tls
$phpmailer->SMTPSecure = "tls";
$phpmailer->From = "[email protected]";
$phpmailer->FromName = "XYZ";
}
and added below code for my contact form to send email.
$headers = array('MIME-Version: 1.0'.'From: '.$_POST['namee'].'<'.$_POST['email'].'>'.'Reply-To: '.$_POST['email']);
$comment = $comment . "\r\n" . "\r\nIP Address: " . $id . "\r\nUser Agent: " . $browser . "\r\nReferrer: " . $referrer;
wp_mail($to,$website,$comment,$headers);
But, It is neither setting the headers properly nor does it send the email with the From address as the one taken from the contact form.
I'm getting emails but the From address in those emails is that of the host server.
I want that the email address taken from the contact form should get set as the From address in the email.
I know that there are hooks to replace the admin email and name, but, that replaces the site admin email address and name and become static. I want that the email address user enters in contact form should be the From address in the email being sent.
How can I do this? Does anybody know about it?
$_POST['namee']
and not$_POST['name']
?