-1

我使用此脚本在评论后发送电子邮件,它是 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();            
4

1 回答 1

0
$first = true;
if($first) {

   ...code...

   $first = false;
 }

但我认为更好地理解组件开发人员的问题在哪里。

于 2013-09-02T14:31:56.843 回答