Title: Email Webhook
Last modified: February 13, 2024

---

# Email Webhook

 *  Resolved [iperez_genius](https://wordpress.org/support/users/iperez_genius/)
 * (@iperez_genius)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/email-webhook/)
 * we currently use your plugin along with Sendgrid to send out our emails.
   I am
   in need to be able to trigger a service call to an api that I own prior to the
   emails being sent out and then another service call when the email is finished
   being sent.
 * Is there a webhook available in the plugin to do that?

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Support [Darshana](https://wordpress.org/support/users/darshanaw/)
 * (@darshanaw)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/email-webhook/#post-17422896)
 * Hi [@iperez_genius](https://wordpress.org/support/users/iperez_genius/),
 * Thanks for reaching out! As I have checked with our developers, we don’t have
   any web hooks for the email-sending lifecycle.
 * Please note that we do not provide support for custom code. However, you should
   be able to use the following code to implement what you need.
 * Fires before an email is sent:
 *     ```wp-block-code
       /**
        * Fires before email sent *
        * Allows to hook after all the preparation before the actual sending.
        *
        * @since 3.3.0
        *
        * @param MailerAbstract $mailer The Mailer object.
        */
       do_action( 'wp_mail_smtp_mailcatcher_send_before', $mailer );
       ```
   
 * Fires after an email is sent:
 *     ```wp-block-code
       /**
        * Fires after email sent *
        * Allow to perform any actions with the data.
        *
        * @since 3.5.0
        *
        * @param MailerAbstract       $mailer      The Mailer object.
        * @param MailCatcherInterface $mailcatcher The MailCatcher object.
        */
       do_action( 'wp_mail_smtp_mailcatcher_send_after', $mailer, $this );
       ```
   
 * I hope this helps. Thanks!
    -  This reply was modified 2 years, 3 months ago by [Darshana](https://wordpress.org/support/users/darshanaw/).
 *  Thread Starter [iperez_genius](https://wordpress.org/support/users/iperez_genius/)
 * (@iperez_genius)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/email-webhook/#post-17524045)
 * Thanks for your reply. In your after event what does “$this” refer too.
 *  Thread Starter [iperez_genius](https://wordpress.org/support/users/iperez_genius/)
 * (@iperez_genius)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/email-webhook/#post-17544820)
 * Darshana, are you certain about the second hook.
 * The first one works fine, however the second one doesn’t fire.
 *  Plugin Support [Darshana](https://wordpress.org/support/users/darshanaw/)
 * (@darshanaw)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/email-webhook/#post-17548853)
 * Hi [@iperez_genius](https://wordpress.org/support/users/iperez_genius/),
 * Based on the details provided by our developers, I can provide the following 
   information.
 * `$this` refers to `$phpmailer` object.
 * Our developers have tested the second function and have confirmed that it is 
   working as expected.
 *     ```wp-block-code
       add_action( 'wp_mail_smtp_mailcatcher_send_after', function ( $mailer, $mailcatcher ) {
         // Do something.
       } );
       ```
   
 * Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Email Webhook’ is closed to new replies.

 * ![](https://ps.w.org/wp-mail-smtp/assets/icon-256x256.png?rev=1755440)
 * [WP Mail SMTP by WPForms - The Most Popular SMTP and Email Log Plugin](https://wordpress.org/plugins/wp-mail-smtp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-mail-smtp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-mail-smtp/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-mail-smtp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-mail-smtp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-mail-smtp/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Darshana](https://wordpress.org/support/users/darshanaw/)
 * Last activity: [2 years, 2 months ago](https://wordpress.org/support/topic/email-webhook/#post-17548853)
 * Status: resolved