What is the advantage of using wp_mail()
over mail()
. Codex says they’re similar, but they seem to be very similar.
Leave a Reply
You must be logged in to post a comment.
What is the advantage of using wp_mail()
over mail()
. Codex says they’re similar, but they seem to be very similar.
You must be logged in to post a comment.
wp_mail()
is a pluggable function: It can be replaced by plugins. Thatâs useful in cases where the regularmail()
doesnât work (good enough), for example when you need extra authentication details. Example: WP Mail SMTPwp_mail()
uses PHPMailer by default, a sophisticated PHP class which offers a lot of useful preprocessing and workarounds for cases wheremail()
is too simple (UTF-8 encoded subject lines, attachments and so on). Just take a look at the bug tracker to get an idea about the complexity of these tasks.wp_mail
offers some hooks for other plugins to change different values:'wp_mail'
'wp_mail_from'
'wp_mail_from_name'
use case'wp_mail_content_type'
'wp_mail_charset'
'phpmailer_init'
(an action)In short: Use
wp_mail()
for interoperability.