问题
A similar question has been asked before by someone else, but there were no answers.
I am sending two emails using Pear Mail, but when debugging why my script was going slow, I discovered it was taking an avg of 10.34 seconds to send both emails.
Am I not setting something that I should? Anything I can change?
Here's my code:
$sendMail = sendMail($to, $subject, $message_body);
function sendMail($to, $subject, $message_body)
{
$headers["From"] = "<my from address>";
$headers["To"] = $to;
$headers["Reply-To"] = "<my reply to>";
$headers["Subject"] = $subject;
$headers["Content-type"] = "text/html";
$params["username"] = "<my username>";
$params["password"] = "<my password>";
$params["host"] = "<my host>";
$mail_object =& Mail::factory("smtp", $params);
$sent = $mail_object->send($headers["To"], $headers, $message_body);
if (PEAR::isError($sent)) {
return "Could Not Send Email Alerts. Please try submitting your request later.";
}
return 1;
}
回答1:
It's likely that the receiving server is performing anti-spam checks on you. These could include reverse DNS checks, blacklist checks (i.e., RBLs), content scanning, and throttling. If you can run a network sniffer to watch the traffic, you might get a clue as to what is happening. You might also want to contact the administrator of the server you're connecting to, and ask what checks are being performed and what rules you might be able to adhere to in order to avoid (or quicken) some of them.
回答2:
check that your server has reverse DNS set up. it could be that the receiving server is trying to verify your identity, and can't resolve your IP address to a name.
来源:https://stackoverflow.com/questions/8143858/pear-mail-going-very-slow-10-seconds-to-send