admin管理员组

文章数量:1431420

I'm looking for a way to hook into the mail function before it sends so I can var_dump the output. Are there any action hooks with the mail message that I can hook into? I'm having trouble finding the wp_mail() function in core. Any other methods of debugging mail output would be greatly appreciated as well.

I'm looking for a way to hook into the mail function before it sends so I can var_dump the output. Are there any action hooks with the mail message that I can hook into? I'm having trouble finding the wp_mail() function in core. Any other methods of debugging mail output would be greatly appreciated as well.

Share Improve this question edited Apr 19, 2019 at 23:44 butlerblog 5,1313 gold badges28 silver badges44 bronze badges asked Aug 5, 2016 at 20:38 psorensenpsorensen 4976 silver badges17 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 4

The first link on Google is to https://developer.wordpress/reference/functions/wp_mail/ which says that wp_mail is in wp-includes/pluggable.php

It also has the full function source code showing that the first active line of the function is:

$atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) );

... which suggests that if you hook into the filter you can capture all of those fields.

Additionally as it's a pluggable function you could also replace it with your own function doing whatever you want with the messages.

本文标签: debugIntercepting wpmail() to view contents