Skip to content
wp-skills
Register
tools/wordpress-mail-function-generator

WordPress Mail Function Generator

WordPress Mail Function Generator is a tool that simplifies sending emails on your WordPress site.

The message's subject line.

Only used when a From email is given — a name with no address is not a header WordPress can send.

Leave blank and WordPress sends as wordpress@yourdomain, which most spam filters treat accordingly. The address should belong to the sending domain.

Comma separated. Each becomes its own entry in the $to array.

Comma separated. Every recipient sees these addresses.

Comma separated, and hidden from the other recipients.

Where replies go when that is not the From address.

The body. With an HTML content type this is sent as markup; with plain text it is sent verbatim, tags and all.

snippet.php
// Send an email through wp_mail()
$to      = array( 'recipient@example.com' );
$subject = '';
$message = '';

$headers = array(
	'Content-Type: text/plain; charset=UTF-8',
);

// wp_mail() returns false when the mailer refuses the message. The reason is
// not in the return value; hook 'wp_mail_failed' to read the WP_Error.
$sent = wp_mail( $to, $subject, $message, $headers );