Why won’t wp_mail() let me set the From: header when plain old PHP mail() will?

Hi @helenyhou:

You can set the header, just not with a parameter. WordPress uses “hooks” and the hooks you need are 'wp_mail_from' and 'wp_mail_from_name' hooks.

Here are the hooks you might add to your theme’s functions.php file to modify the "From:" header when using wp_mail() to the email address Helen Hou-Sandi <[email protected]>:

add_filter('wp_mail_from','yoursite_wp_mail_from');
function yoursite_wp_mail_from($content_type) {
  return '[email protected]';
}
add_filter('wp_mail_from_name','yoursite_wp_mail_from_name');
function yoursite_wp_mail_from_name($name) {
  return 'Helen Hou-Sandi';
}

Leave a Comment

error code: 523