Reputation: 49
I created a php application at dan.creativeloafing.com. This just takes form data and builds an html page with it, then emails the contents of that page to [email protected]. A couple days ago, it stopped working. I have been trying to figure this out ever since. I was using the mail() php function and have switched it over to the PHPMailer Library. This is supposedly sending the emails and I get confirmation, but nobody ever recieves the email and I get no bounceback or any errors. This is the jist of the code:
//PHPMailer
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'relay-hosting.secureserver.net'; // Specify main and backup server
$mail->Port = 25;
$mail->SMTPAuth = false; // Enable SMTP authentication
$mail->SMTPSecure = 'tsl'; // Enable encryption, 'ssl' also accepted
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = '*******'; // SMTP password
$mail->SMTPDebug = 0;
$mail->WordWrap = 50;
$mail->From = '[email protected]';
$mail->FromName = 'DAN Application';
$mail->addAddress('[email protected]'); // Name is optional
$mail->addReplyTo($repEmail);
$mail->addCC('[email protected]');
$mail->isHTML(true);
$mail->Subject = "New DAN Request: ".$campaignName;
$mail->msgHTML(file_get_contents('./tmp/DAN_REQUEST_'.$specialString.$randomNumber.'.html'));
if(!$mail->send()) {
echo '<br />Proposal could not be sent.<br />';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
} else {
echo 'Proposal has been sent';
}
The script always reaches 'Proposal has been sent.' too. This is driving me crazy!
Upvotes: 2
Views: 8482
Reputation: 23
Isn't:
$mail->SMTPSecure = 'tsl';
supposed to be:
$mail->SMTPSecure = 'tls';
Upvotes: 1
Reputation: 1548
Use try...catch and PHPMailer(true); https://github.com/Synchro/PHPMailer/blob/master/examples/exceptions.phps
//Create a new PHPMailer instance
//Passing true to the constructor enables the use of exceptions for error handling
$mail = new PHPMailer(true);
try {
mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'relay-hosting.secureserver.net'; // Specify main and backup server
$mail->Port = 25;
$mail->SMTPAuth = false; // Enable SMTP authentication
$mail->SMTPSecure = 'tsl'; // Enable encryption, 'ssl' also accepted
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = '*******'; // SMTP password
$mail->SMTPDebug = 0;
$mail->WordWrap = 50;
$mail->From = '[email protected]';
$mail->FromName = 'DAN Application';
$mail->addAddress('[email protected]'); // Name is optional
$mail->addReplyTo($repEmail);
$mail->addCC('[email protected]');
$mail->isHTML(true);
$mail->Subject = "New DAN Request: ".$campaignName;
$mail->msgHTML(file_get_contents('./tmp/DAN_REQUEST_'.$specialString.$randomNumber.'.html'));
$mail->send();
echo 'Proposal has been sent';
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
Upvotes: 0
Reputation: 49
So what was happening here is that godaddy was blocking emails that included my domain name in them. I am not sure if this was a spam issue, but they are currently looking into it. I have gotten the emails to send using a simple mail() function and by removing any references to omgsurvey.com in the email. Silly, this mail was only ever sent to two email addresses!
Upvotes: 1