PHP可以从开发人员的机器上找到GMail消息,但不能从实时服务器上找到
我构建了一个小脚本,用于在Joomla网站内运行电子邮件发送的端到端测试:PHP可以从开发人员的机器上找到GMail消息,但不能从实时服务器上找到,php,gmail,imap,Php,Gmail,Imap,我构建了一个小脚本,用于在Joomla网站内运行电子邮件发送的端到端测试: $testMailer =& JFactory::getMailer(); $testMailer->setSender(SENDER); $testMailer->addReplyTo(SENDER); $testMailer->addRecipient(TEST_EMAIL); $subject = 'Automatic test '.md5(uniqid()); $testMaile
$testMailer =& JFactory::getMailer();
$testMailer->setSender(SENDER);
$testMailer->addReplyTo(SENDER);
$testMailer->addRecipient(TEST_EMAIL);
$subject = 'Automatic test '.md5(uniqid());
$testMailer->setSubject($subject);
$testMailer->setBody('This message is automatically retrieved. Please ignore.');
?>
<h2>Testing Joomla email sending functionality</h2><?php
flush();
if ($testMailer->Send() !== true) {
echo '<p>ERROR - Mail Sending failed</p>';
}else{
echo '<p>Email sent...</p>';
flush();
$sleep = 5;
$progress = 0;
$max = 300;
set_time_limit($max+30);
$found = 0;
$mbox = imap_open(TEST_IMAP_SERVER, TEST_EMAIL, TEST_PASSWORD);
if (!$mbox){
echo '<p>ERROR - Login to '.TEST_EMAIL.' failed</p>';
foreach (imap_errors() as $error){
echo '<p>'.$error.'</p>';
}
die();
}else{
while (!$found && $progress < $max){
$result = imap_search($mbox, 'SUBJECT "'.$subject.'"');
foreach($result as $msgno) {
$headers = imap_fetchheader($mbox, $msgno);
if ($headers){
echo '<p>OK - EMail received</p>';
imap_delete($mbox,$msgno);
$found = 1;
die();
}
}
}
if (!$found){
$progress+=$sleep;
echo '<p>Waiting '.$sleep.' seconds to try again...('.$progress.' seconds total wait)</p>';
flush();
sleep($sleep);
}
}
if (!$found){
echo '<p>ERROR Giving up after '.$max.' seconds</p>';
}
}
有什么想法吗?如果该组件支持您想在其中使用的环境(Amazon EC2),请与该组件的供应商联系。@hakre-我已经编写了这个组件。哇,那么我想说您一定是解决这个问题的最多才多艺的人。也许它包装了另一个你没有写的库?如果是这样,请联系该库的供应商,检查它是否支持该环境。另外,我也不清楚您描述的是哪种问题。这些是不同的邮件服务器吗?或者只是访问同一邮件服务器执行代码的不同框?同时尝试获取错误消息。这取决于您在内部使用的库。当脚本在其他服务器上运行时,就会出现问题。不幸的是,没有错误消息,在一台服务器上,在另一台服务器上找不到任何消息—它们总是被找到。
telnet imap.gmail.com 993
Trying 74.125.133.108...
Connected to gmail-imap.l.google.com.
Escape character is '^]'.