do_action_ref_array( 'phpmailer_init', PHPMailer $phpmailer )
Fires after PHPMailer is initialized.
Parameters
-
$phpmailer
PHPMailer -
The PHPMailer instance (passed by reference).
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.
Source
File: wp-includes/pluggable.php
.
View all references
do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
Changelog
Version | Description |
---|---|
2.2.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
If you call
$phpmailer->setFrom()
, it’s often important to explicitly set the third parameter tofalse
, to tell PHPMailer to not override theSender
header. The parameter defaults totrue
, and using that can cause messages to be rejected.See #37736 for details.
Example migrated from Codex:
This is an example of establishing an SMTP connection using the `
phpmailer_init
` action: