PHPmailer stuck on mail.php AND being marked as spam issue

348 views Asked by At

I've got an issue with PHPmailer getting stuck on my mail.php screen (usually it forwards the user to a success.html page). I've turned on error reporting, but still nothing shows up. I'm quite a noob at PHP, but it was working on my test URL before I moved it to the actual URL I wanted it to be on (just a few directories over on my server). Now I'm stuck on a white screen with no errors.

ALSO, I'm having an issue where on hotmail (and maybe some other providers--Gmail is working fine now) it's marking the emails as spam. I fixed a reverse DNS issue, but it's still marking the emails as spam. Any ideas on how to fix it? Please check my body and see if the content raises any red flags.

Here's the code:

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once('/var/www/includes/PHPMailer/PHPMailerAutoload.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

//gather variables from form//
$gmname =   $_POST['gmname'];
$charname = $_POST['charname'];
$email = $_POST['email'];
$date = $_POST['date'];
$time = $_POST['time'];
$bantype = $_POST['radiogroup'];
$banreason = $_POST['banreason'];
//end gather//

$mail             = new PHPMailer();
$mail->CharSet = 'UTF-8';

$body             ="Attention account holder,<br \>This is a notice informing you that your Ashran account has been suspended. Please review the following information.<br \><br \>Account Name: $email<br \>Character Name: $charname<br \>Server: US - Grommash<br \>Ban Reason: $banreason<br \>Ban Type: $bantype<br \>Ban End Date: $date $time Server Time<br \>Banning staff member: $gmname<br \><br \>If you would like to appeal your ban because you feel that you were incorrectly punished, please follow the instructions in the following thread: <a href="http://forum.ashran.com/index.php?/topic/9461-ban-appeals/#entry68417">Click Here</a><br \><br \>Do NOT reply to this email.";
//$body             = eregi_replace("[\]",'',$body);//

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = "smtp.gmail.com"; // SMTP server
$mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "tls";                 //   sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 587;                   // set the SMTP port for the GMAIL server
$mail->Username   = "[email protected]";  // GMAIL username
$mail->Password   = "----------";            // GMAIL password

$mail->SetFrom('[email protected]', '------ -----');

$mail->AddReplyTo("[email protected]","----- -----");

$mail->Subject    = "Ashran - Account Suspension Notice";

//$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$address = "$email";
$mail->AddAddress($address);

//Sets URL for forward after completion
$url = 'success.html';
//

if(!$mail->Send()) {

    echo "Mailer Error: " . $mail->ErrorInfo; 

} else {

    header( "Location: $url" );
    echo "Ban notice sent!!!";
}

?>

1

There are 1 answers

0
Jesse On BEST ANSWER

For the spam folder issue: If you find you're in a process where you're tweaking your content and then checking if it fixed your delivery problems, you can use inboxtrail.com's seed-based email deliverability test to see which email providers are dumping you to the spam folder after each content change. It's probably a good idea to re-test all the top providers, since for all you know a content change that solves the problem on hotmail could create new problems on gmail or yahoo or something. This should also tell you if the way your email server is configured is setting off any red flags.