Updating an entry after an event action within onSaveEntry I have written a plugin that checks if an entry has been saved and sends the user an email from within an onSaveEntry event. This works fine. But I now need to also update this entry to flag that an email has been sent so that subsequent saves do not fire the event. I have tried adding the following but these lines do not work and cause an infinite loop.

$entry-&gt;setContentFromPost(['emailSent' =&gt; '1']);
craft()-&gt;entries-&gt;saveEntry($entry);


Is there a way to re-save the entry after the email has been sent so as just to update the emailSent field?

Full function:

public function onSaveEntry(Event $event)
{
    $entry = $event-&gt;params['entry'];
    if($entry-&gt;sectionId == '12345') {
        if($user = craft()-&gt;users-&gt;getUserById($entry-&gt;authorId)) {
            if($entry-&gt;enabled &amp;&amp; !$user-&gt;admin &amp;&amp; !$entry-&gt;emailSent) {

                // Send Approved Mail
                $email = new EmailModel();
                $email-&gt;fromEmail = 'me@mydomain.com';
                $email-&gt;toEmail = $user-&gt;email;
                $email-&gt;subject = 'Email Subject';
                $email-&gt;body    = '&lt;p&gt;Email Body&lt;/p&gt;';
                craft()-&gt;email-&gt;sendEmail($email);

                $entry-&gt;setContentFromPost(['emailSent' =&gt; '1']);
                craft()-&gt;entries-&gt;saveEntry($entry);
            }
        }
    }
    return $event;
}
Use craft()-&gt;elements-&gt;saveElement the second time. It will work exactly the same but won't trigger the onSaveEntry event.