Some Php Configuration

Hi dopebrest,

You need to send 2 emails using the same smtp configuration in this case while specifying a different address in each case.

<?php

function newMail(){
	$mail = new \PHPMailer\PHPMailer\PHPMailer(true);
	$mail->SMTPDebug = CONTACTFORM_PHPMAILER_DEBUG_LEVEL;
	$mail->isSMTP();
	$mail->Host = CONTACTFORM_SMTP_HOSTNAME;
	$mail->SMTPAuth = true;
	$mail->Username = CONTACTFORM_SMTP_USERNAME;
	$mail->Password = CONTACTFORM_SMTP_PASSWORD;
	$mail->SMTPSecure = CONTACTFORM_SMTP_ENCRYPTION;
	$mail->Port = CONTACTFORM_SMTP_PORT;
	$mail->Priority = 1;
	$mail->setFrom(CONTACTFORM_FROM_ADDRESS, CONTACTFORM_FROM_NAME);
	return $mail;
}

// SEND EMAIL FOR INTERNAL
$mail = newMail();
$mail->addAddress(CONTACTFORM_TO_ADDRESS, CONTACTFORM_TO_NAME);
$mail->Subject = "Dopenews-Contact us ".$_POST['Dopenews Support'];
$mail->Body    = <<<EOT
Name: {$_POST['name']}
Email: {$_POST['email']}
Message:
{$_POST['message']}
EOT;
$mail->send();


// SEND EMAIL FOR VISITOR
$mail = newMail();
$mail->addAddress($_POST['email'], $_POST['name']);
$mail->addReplyTo(CONTACTFORM_TO_ADDRESS, CONTACTFORM_TO_NAME);
$mail->Subject = "Dopenews-Contact us ".$_POST['Dopenews Support'];
$mail->Body    = <<<EOT
Name: {$_POST['name']}
Email: {$_POST['email']}
Message:
Thanks for contacting us we will Respond Shortly.
EOT;
$mail->send();

Cheers!

2 Likes