WordPress Tutorials
Intercepting Outgoing Email with the wp_mail Filter
The filter is the supported way to rewrite mail before it is sent, and it has one blind spot: a plugin that redefines the mail function entirely never fires it. That is exactly what many delivery plugins do.