WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 18 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.