I've set a mail function with PHP Mailer and the mail is being received but it doesn't redirect after, this is the code:
//more code
require("includes/class.phpmailer.php");
$mail = new PHPMailer();
$mail->From = $email;
$mail->FromName = $name;
$mail->AddAddress("mytargetaddres@example.com");
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = "Contact";
$mail->Body = "my body";
$mail->IsSMTP();
$mail->Host = "my.host";
$mail->SMTPAuth = true;
$mail->Username = "mytargetaddres@example.com";
$mail->Password = "mypassword";
if($mail->Send()){
header('Location: thanks.php');
}else{
header('Location: error.php');
}
I've the exact same setup in another website on the same server and it works but here instead of redirecting it shows a blank page.
Edit: after showing erros it says this:
SMTP Error: Data not accepted.
Warning: Cannot modify header information - headers already sent by (output started at /public_html/mail.php:1) in /public_html/mail.php on line 37
Line 37 is: header('Location: error.php');