Mailgun for WordPress icon
Email & Marketing

Mailgun for WordPress hooks reference

  • By Mailgun
  • v2.2.3
  • Updated

Mailgun for WordPress 2.2.3 has 4 actions and 11 filters, read directly from its source code on Nov 17, 2026. The list updates automatically when a new version is released.

How to use these hooks

Actions let you run your own code at a specific moment. Filters let you change a value before the plugin uses it. Put your code in a child theme's functions.php or a code-snippets plugin, never in the plugin's own files, because updates overwrite them.

functions.phpyour child theme
// Run your own code when Mailgun for WordPress fires an action
add_action( 'phpmailer_init', function( $phpmailer ) {
	// Your code runs here.
}, 10, 1 );

// Change a value Mailgun for WordPress is about to use
add_filter( 'wp_mail_charset', function( $charset ) {
	// Change $charset here.
	return $charset;
}, 10, 1 );

Parts of a name in {braces} are filled in at runtime (for example a post type or field ID). Choose Example on any hook for a ready-to-edit snippet.

All hooks

  • includes/wp-mail-api.php line 396 · used in 2 places
    /**
     * Fires after PHPMailer is initialized.
     */
    do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
  • includes/wp-mail-api.php line 661 · used in 2 places
    /**
     * Filters the default wp_mail() charset.
     */
    apply_filters( 'wp_mail_charset', $charset );
  • includes/wp-mail-api.php line 641 · used in 2 places
    /**
     * Filters the wp_mail() content type.
     */
    apply_filters( 'wp_mail_content_type', $content_type );
  • includes/wp-mail-api.php line 576 · used in 2 places
    /**
     * This filter is documented in wp-includes/pluggable.php
     */
    do_action( 'wp_mail_failed', new WP_Error('wp_mail_failed', $e->getMessage(), $mail_error_data) );
  • wp_mail_from

    filter
    includes/wp-mail-api.php line 559 · used in 2 places
    /**
     * Filters the email address to send from.
     */
    apply_filters( 'wp_mail_from', $from_email );
  • includes/wp-mail-api.php line 567 · used in 2 places
    /**
     * Filters the name to associate with the "from" email address.
     */
    apply_filters( 'wp_mail_from_name', $from_name );
  • mailgun_tags

    filter
    includes/wp-mail-api.php line 330
    /**
     * Filter tags.
     */
    apply_filters( 'mailgun_tags', $body['o:tag'], $to, $subject, $message, $headers, $attachments, $region, $domain );
  • includes/wp-mail-api.php line 723
    /**
     * Fires after PHPMailer has successfully sent an email. The firing of this
     * action does not necessarily mean that the recipient(s) received the email
     * successfully. It only means that the `send` method above was able to process
     * the request without any errors.
     */
    do_action( 'wp_mail_succeeded', $mail_data );
  • list_address

    filter
    includes/widget.php line 52
    apply_filters( 'list_address', $instance['list_address'] );
  • includes/wp-mail-api.php line 43
    do_action( 'mailgun_error_track', $error );
  • includes/wp-mail-api.php line 448
    apply_filters( 'mg_mutate_attachments', $attachments );
  • includes/wp-mail-api.php line 442
    apply_filters( 'mg_mutate_message_body', $body );
  • includes/wp-mail-api.php line 271
    apply_filters( 'mg_mutate_to_rcpt_vars', $to );
  • includes/wp-mail-api.php line 75
    apply_filters( 'mg_use_recipient_vars_syntax', null );
  • wp_mail

    filter
    includes/wp-mail-api.php line 142
    apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) );

Generated from Mailgun for WordPress's GPL-licensed source code. Hooks inside bundled third-party libraries are not listed.

Can't find the right hook?

We can build the customisation for you. Describe what you need: