Hello everyone i have been getting this error and dont know how to fix it.
{"response":"error","message":"You must provide at least one recipient email address."}
This is the code.
<?php
require_once('phpmailer/class.phpmailer.php');
$mail = new PHPMailer();
//recipient data
$toemail = $_POST['contact@spadaweb.com']; // Your Email Address
$toname = $_POST['Spadaweb, INC']; // Your Name
//sender data
$name = $_POST['contact-form-name'];
$email = $_POST['contact-form-email'];
$service = $_POST['contact-form-service'];
$subject = $_POST['contact-form-subject'];
$message = $_POST['contact-form-message'];
if( isset( $_POST['contact-form-submit'] ) ) {
if( $name != '' AND $email != '' AND $subject != '' AND $message != '' ) {
$body = "Name: $name <br><br>Email: $email <br><br>Service: $service <br> <br>Message: $message";
$mail->SetFrom( $email , $name );
$mail->AddReplyTo( $email , $name );
$mail->AddAddress( $toemail , $toname );
$mail->Subject = $subject;
$mail->MsgHTML( $body );
$sendEmail = $mail->Send();
if( $sendEmail == true ):
$arrResult = array ('response'=>'success');
else:
$arrResult = array ('response'=>'error','message'=>$mail->ErrorInfo);
endif;
} else {
$arrResult = array ('response'=>'empty');
}
} else {
$arrResult = array ('response'=>'unexpected');
}
echo json_encode($arrResult);
?>
I have changed the email etc to mine and i keep getting the above error? Currently hosted on a bluehost vps cent os server as well. DKIM is enabled on this particular account? Thanks for looking over the problem!
$toemail = $_POST['contact@spadaweb.com']; // Your Email Address
$toname = $_POST['Spadaweb, INC']; // Your Name
This needs to be changed since you are giving it the actual variables and not trying to get the posts.
$toemail = 'contact@spadaweb.com'; // Your Email Address
$toname = 'Spadaweb, INC'; // Your Name
Now it should be able to send.