What is the advantage of using wp_mail?

What is the advantage of using wp_mail() over mail(). Codex says they’re similar, but they seem to be very similar.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

wp_mail() is a pluggable function: It can be replaced by plugins. That’s useful in cases where the regular mail() doesn’t work (good enough), for example when you need extra authentication details. Example: WP Mail SMTP

wp_mail() uses PHPMailer by default, a sophisticated PHP class which offers a lot of useful preprocessing and workarounds for cases where mail() 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.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x