Sending email twice (Wordpress)
<p>I am sending an email when a post type goes to pending.</p>

<p>Everything works fine but the email is sent twice.</p>

<p>Here's my code: </p>

<pre><code>function pendingPost($id)
{
$type = get_post_type($id);
$post_user = wp_get_current_user($id);
$edit_link = get_edit_post_link($id);
$to = "test@gmail.com";
$subject = "New Entry needs to be approved";
    $message = "
            &lt;html&gt;
            &lt;head&gt;
            &lt;title&gt;Pending notification&lt;/title&gt;
            &lt;/head&gt;
            &lt;body&gt;
            &lt;p&gt;Hi,&lt;/p&gt;
            &lt;p&gt;A new entry has been submited.&lt;/p&gt;
            &lt;p&gt;Title : ".get_the_title($id)."&lt;/p&gt;
            &lt;p&gt;Type : ".substr($type, 0, -1)."&lt;/p&gt;
            &lt;p&gt;Author : ".$post_user-&gt;display_name."&lt;/p&gt;
            &lt;br /&gt;
            &lt;p&gt;Click &lt;a href='".$edit_link."'&gt;here&lt;/a&gt; to approve it.&lt;/p&gt;
            &lt;/body&gt;
            &lt;/html&gt;
            ";

    $headers = array('Content-Type: text/html; charset=UTF-8');

    $mail = wp_mail($to, $subject, $message,$headers);

}

add_action('pending_posttype', 'pendingPost', 10, 1);
</code></pre>

<p>Hope someone can help.</p>

<p>Thanks in advance.</p>