我使用此脚本在评论后发送电子邮件,它是 joomla 的k2 组件,但我每次收到 2 封电子邮件,我如何计算运行并仅启动此脚本 1 次?
我的代码看起来是这样的:
$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();