我正在尝试用一个插件在wordpress上设置一个登录页面-即将到来的CC。它有一个订阅盒。每次有人注册订阅时事通讯时,我都会收到一封来自wordpress@mydomain.com的电子邮件,其中包含通知。我如何改变它,使我从订阅者的邮件id本身而不是wordpress@mydomian.com.In获取邮件,并从订阅者的电子邮件id而不是wp_mail发送邮件。这是我在插件文件中发现的-
/**
* [ajax_newsletter_subscribe description]
* @return [type] [description]
*/
public function ajax_newsletter_subscribe() {
check_ajax_referer( 'cc-cs-newsletter-subscribe' );
$to_email = $this->get_option('newsletter', 'email') ? $this->get_option('newsletter', 'email') : get_option( 'admin_email' );
if(filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$sent = wp_mail(
$to_email,
__('You have a new subscriber!', $this->plugin_slug),
sprintf(__("Hello,\n\nA new user has subscribed through your Coming Soon page.\n\nSubscriber's email: %s", $this->plugin_slug), $_POST['email'])
);
if($sent) {
print json_encode(array('status' => 'ok'));
die();
}
}
print json_encode(array('status' => 'error'));
die();
}发布于 2014-12-08 01:20:20
您可以设置邮件$headers,其中From
$headers = array();
$headers[] = 'From: ' . $_POST['email'] . ' <' . $_POST['email'] . '>';
$sent = wp_mail(
$to_email,
__( 'You have a new subscriber!', $this->plugin_slug ),
sprintf( __( "Hello,\n\nA new user has subscribed through your Coming Soon page.\n\nSubscriber's email: %s", $this->plugin_slug ), $_POST['email'] ),
$headers
);检查Codex。
https://stackoverflow.com/questions/27345294
复制相似问题