phpmailer_init WordPress Action Hook

The phpmailer_init hook allows you to modify the PHPMailer class before it is used by WordPress. This can be useful if you need to add extra headers, or change the way that email is sent.

do_action_ref_array( 'phpmailer_init', PHPMailer $phpmailer ) #

Fires after PHPMailer is initialized.


Parameters

$phpmailer

(PHPMailer)The PHPMailer instance (passed by reference).


Top ↑

More Information

The wp_mail() function relies on the PHPMailer class to send email through PHP’s mail function. The phpmailer_init action hook allows you to hook to the phpmailer object and pass in your own arguments.

This action is initiated with `do_action_ref_array` rather than `do_action`. You still hook to it with `do_action`. However, there are some notable differences:

  • If you pass an array to `do_action_ref_array()`, each element’s value of that array is passed as a separate parameter to the callback.
  • If you pass an array to `do_action()`, the complete array is passed as a single argument including any keys.

Top ↑

Source

File: wp-includes/pluggable.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
2.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More