Event onPublishDraft not firing We are still trying to make a custom mail plugin. We have one problem left. When someone makes a draft, and later publishes it, only the onSaveEntry fires but without NewEntry. So we were trying to use the onPublishDraft instead. But we can't get it to fire. I'm using Craft CMS 2.6.3 Pro

this is what we tried so far:



craft()-&gt;on('entryRevisions.onPublishDraft', function(Event $event){}
craft()-&gt;on('entryRevisions.publishDraft', function(Event $event){}
craft()-&gt;on('publishDraft', function(Event $event){}
craft()-&gt;entryRevisions-&gt;onPublishDraft = function(Event $event) {}
craft()-&gt;entryRevisions-&gt;publishDraft = function(Event $event) {}


this is the regular on save entry we use, maybe there is another way to catch a draft that is being published;

craft()-&gt;on('entries.saveEntry', function(Event $event){ 
if ($event-&gt;params['isNewEntry'] &amp;&amp; $entry-&gt;status == 'live'){    }});


Hope you guys know how to do that

UPDATE

I did do a test with the exact code Brad gave, but it still didn't do anything... This is how my test starts;

public function init(){
    parent::init();

    craft()-&gt;on('entryRevisions.onPublishDraft', function(Event $event) {
        Craft::log("draft published", LogLevel::Info, true);
    });

    craft()-&gt;on('entries.saveEntry', function(Event $event) {
        Craft::log("Entry saved", LogLevel::Info, true);
    });
}


Only the second one gets logged when I change the status of the post, the first never.

*****************************************
2017/12/21 21:29:54 [info] [application] [Forced] Entry saved
*****************************************
Maybe you already solved your issue but I wanted to explain what I did the last time... You can make use of the craft_content table and it's implementation in Craft 2 that fetches and includes all columns no matter of the field layout.

Make use of the light switch field, if you already have one that you are not going to use in your specific entry type you can abuse that, otherwise create a new one. You don't want to include this field into your field layout, you'll only work with it in your php code. Instead of looking if your entry is a new entry you are going to check if that field is set to true or false. You can change the field however you like, it is saved correctly and populated correctly, but your clients won't be able to change it manually (so they can't resend the mail by mistake. 

Below is the code I used, my requirement was to send the mail as soon as the entry was activated (they were saved as disabled from a frontend form). Since you asked in a comment how to check when an entry goes from disabled to enabled I thought it might be helpful.

craft()-&gt;on('entries.onBeforeSaveEntry', function(Event $event) {
        if(!$event-&gt;params['isNewEntry']){
            /* @var $entry EntryModel */
            $entry = $event-&gt;params['entry'];
            if($entry-&gt;section-&gt;handle === "projects"){
                $oldEntry = craft()-&gt;entries-&gt;getEntryById($entry-&gt;id);
                // check if the entry was disabled and is now enabled and if no mail was already send
                if($oldEntry-&gt;enabled === false &amp;&amp; $entry-&gt;enabled === true &amp;&amp; $entry-&gt;getContent()-&gt;getAttribute('mailSended') === 0){
                    $originalPath = craft()-&gt;templates-&gt;getTemplatesPath();
                    craft()-&gt;templates-&gt;setTemplatesPath(CRAFT_TEMPLATES_PATH);

                    $html = craft()-&gt;templates-&gt;render('email/type/activateProject.twig', array(
                        'entry' =&gt; $entry,
                        'userFullName'  =&gt; $entry-&gt;getContent()-&gt;getAttribute('firstName') . " " . $entry-&gt;getContent()-&gt;getAttribute('lastName')
                    ));

                    if($html){
                        craft()-&gt;rodach-&gt;sendMail($html, Craft::t('email_subject_activate_entry'), $entry-&gt;eMail);
                        $entry-&gt;getContent()-&gt;setAttribute('mailSended', 1);
                    }

                    craft()-&gt;templates-&gt;setTemplatesPath($originalPath);
                }
            }
        }
    });