Send mail, similar to PHP’s mail

A true return value does not automatically mean that the user received the email successfully. It just only means that the method used was able to process the request without any errors.

Using the two ‘wp_mail_from’ and ‘wp_mail_from_name’ hooks allow from creating a from address like ‘Name ‘ when both are set. If just ‘wp_mail_from’ is set, then just the email address will be used with no name.

The default content type is ‘text/plain’ which does not allow using HTML. However, you can set the content type of the email by using the


wp_mail( $to, $subject, $message, $headers = '', $attachments = array() )
 (string|array) Array or comma-separated list of email addresses to send message.
 (string) Email subject
 (string) Message contents
 (string|array) Optional. Additional headers.
Default: ''
 (string|array) Optional. Files to attach.
Default: array()


(boolean) Whether the email contents were sent successfully.


function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
	// Compact the input, apply the filters, and extract them back out

	 * Filters the wp_mail() arguments.
	 * @since 2.2.0
	 * @param array $args A compacted array of wp_mail() arguments, including the "to" email,
	 *                    subject, message, headers, and attachments values.
	$atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) );

	if ( isset( $atts['to'] ) ) {
		$to = $atts['to'];

	if ( !is_array( $to ) ) {
		$to = explode( ',', $to );
307 more lines...
WP Trac GitHub

Link here