我在PHP中有一个脚本,使用套接字连接邮件服务器,使用fsockopen,用于Gmail,Yahoo,Hostgator的邮件地址。
一旦套接字连接成功,我必须从中读取数据。在阅读Gmail数据时,雅虎会在1秒内返回,而Hostgator和其他人则需要5秒钟才能读取数据。
所以,我担心的是如何减少时间。
以下是我的脚本:
<?php
$mx = 'gmail-smtp-in.l.google.com'; // It takes only 200ms
//$mx = 'imailv.emirates.net.ae'; // It takes only 400ms
//$mx = 'mail.trantech.com'; // It takes around 6000ms(Problem is
here)
$handle = @fsockopen($mx, 25 , $errno, $errstr, 5);
echo fgets($handle);
?>
也许这个解决方案不适合您的工作流程,但您可以使用邮件发送服务(例如SendGrid,Amazon SES),它将允许您: