WordPress.org

Ready to get started?Download WordPress

Codex

Plugin API/Filter Reference/wp mail

This article is a ROUGH DRAFT. The author is still working on this document, so please do not edit this without the author's permission. The content within this article may not yet be verified or valid. This information is subject to change.

Contents

Description

The wp_mail filter hook allows you to filter the arguments that are passed to the wp_mail() function. The arguments for wp_mail() are passed through the filter as an array.

Parameters

$args
(array) (required) (to,subject,message,headers,attachments)
Default: None

Examples

add_filter( 'wp_mail', 'my_wp_mail_filter' );
function my_wp_mail_filter( $args ) {
	$new_wp_mail = array(
		'to'          => $args['to'],
		'subject'     => $args['subject'],
		'message'     => $args['message'],
		'headers'     => $args['headers'],
		'attachments' => $args['attachments']
	);
	
	return $new_wp_mail;
}

Notes

$attachments should be an array. If it is not, it will be converted to one by the wp_mail function after the filter.

Change Log

Since: Version 2.2

$attachments argument added in Version 2.7

Source Files

wp_mail is located in wp-includes/pluggable.php

Related