[wp-hackers] Customize Wordpress Emails

Andrew Nacin wp at andrewnacin.com
Fri Dec 10 03:40:56 UTC 2010

On Thu, Dec 9, 2010 at 7:14 PM, John Blackbourn
<johnbillion+wp at gmail.com<johnbillion%2Bwp at gmail.com>
> wrote:

> On Thu, Dec 9, 2010 at 11:53 PM, Ryan Bilesky <rbilesky at gmail.com> wrote:
> > Hence it just makes sense to add functionality to my plugin to just
> suppress
> > wp_mail and send out the emails myself so I have the full control over
> the
> > process without hacking the core function.
> Hey Ryan,
> The wp_mail() function is in the 'wp-includes/pluggable.php' file
> meaning it can be completely overridden by a plugin. Makes life nice
> and simple!

I'd avoid that though. I find most pluggable functions rather lame. Unless
you're trying to replace the entire authentication system with something
else, there's generally a great way to modify a lot of the pluggable
functions via actions and filters.

Instead, use the phpmailer action to simply modify the entire object as you
wish. You can easily trigger SMTP that way.

To actually modify the content, there's another filter that allows that
(though the phpmailer action would work too), in wp_mail() I think. But a
lot of the registration/notification emails are also pluggable. Overriding
those are also rather sane, as all there is, is the text and a call to
wp_mail() in most cases.


More information about the wp-hackers mailing list