whenever $mail->isSMTP(); is set in phpmailer it "hangs" for about 1 minute, then it redirects to a: 500 Service Unavailable page with XID: 2060448470.
BUT one minute later i GET the mail that was sent. in the mail i can read: Received-SPF: pass (google.com: domain of admin@skivbasar.se designates 2a00:16d8:0:4::200 as permitted sender)
When i remove "$mail->isSMTP();" the email get sent right away BUT they dont get SPI = pass: spf=none (google.com: 117658@atapa01.citynetwork.se does not designate permitted sender hosts).
I really need SMTP to work since i got a lots of lost mails in the past. I've spent several days looking for a solution including 20+articles here on stackoverflow.
I've re-tried the sample code several times from both worxware and github. It's always "$mail->isSMTP();" that refuses to work propperly.
Here is my mail code:
require("PHPMailerAutoload.php");
require("class.phpmailer.php");
require("class.smtp.php");
$mail = new PHPMailer();
$mail->Host = "mail.skivbasar.se";
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->IsSMTP();
$mail->Username = "-----.se"; // SMTP username
$mail->Password = "-------"; // SMTP password
$mail->AddReplyTo($replyto);
$mail->From = "admin@skivbasar.se";
$mail->FromName = "skivbasar.se";
$mail->AddAddress($row['email']);
$mail->Subject = $row['subject'];
$mail->Body = $row['message'];
$mail->WordWrap = 150;
if(!$mail->Send()) {
$error = true;
} else {
$error = false;
}
you can access a testpage to see the error in action at: http://skivbasar.se/action/mail/t3.php
UPPDATE:
Thank you so much for replying Synchro! You seem to be a real phpmailer expert!
i've tried both tls and ssl countless times and even commenting the line and using both port 587 and 465. Both actually works to send mail as long as "isSMTP" is of.
The real problem i'm trying to solve is why the script hangs for 1 minute whenever "isSMTP" is set but still send the mail after redirecting to the 500 page.
the softfail ones without isSMTP is being sent by: from smtp02.mailout.citynetwork.se (mailout.citynetwork.se. [91.123.193.90])
and the passed (but hanged) ones are being sent by: from smtp03.citynetwork.se (mail.citynetwork.se. [91.123.193.200]).
Is feels like the script is waiting for a reply from the mailserver for 60 seconds (like a HELO) and when the server does not respond. it send the mail anyway after 60 minutes. I've read about this somewhere. I also found some entries in the code where it refers to "HELO" like in class.phpmailer.php on line 1340 "// We must resend HELO after tls negotiation".
Since it's redirect to a 500 page i cant print any error messages. I also dont have access to my log. But it works with "isSMTP" on localhost, it's only when the script is run online is hangs like this.