我使用此脚本在评论后发送电子邮件,它是来自joomla的 k2组件,但每次收到2封电子邮件,我如何计算运行并且只启动此脚本一次?
我的代码看起来如此:
$mailer =& JFactory::getMailer();
$config =& JFactory::getConfig();
$sender = array(
$config->getValue( 'config.mailfrom' ),
$config->getValue( 'config.fromname' ) );
$mailer->setSender($sender);
$recipient = explode(",", " marco3pollini@gmail.com");
$mailer->addRecipient($recipient);
$mailer->setSubject(JText::_('New comment is arrived'));
if (!trim($commentURL)=="") {
$commentURL = "Site: ". $commentURL. "\n";
}
$body = "Name: ". $userName. "\n". "E-mail: ". $commentEmail. "\n". $commentURL. "Comment: ". $commentText;
$mailer->setBody($body);
$mailer->isHTML(true);
$mailer->Send();
答案 0 :(得分:0)
$first = true;
if($first) {
...code...
$first = false;
}
但我认为可以更好地了解组件开发人员的问题在哪里。