• Resolved iperez_genius

    (@iperez_genius)


    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

    (@darshanaw)

    Hi @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:

    /**
     * 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:

    /**
     * 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 1 year, 1 month ago by Darshana.
    Thread Starter iperez_genius

    (@iperez_genius)

    Thanks for your reply. In your after event what does “$this” refer too.

    Thread Starter iperez_genius

    (@iperez_genius)

    Darshana, are you certain about the second hook.

    The first one works fine, however the second one doesn’t fire.

    Plugin Support Darshana

    (@darshanaw)

    Hi @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.

    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.