I am trying to setup a landing page on wordpress with a plugin - Coming Soon CC. It has a subscription box. Every time someone sign up for the newsletter I get an email from wordpress@mydomain.com with the notification. How can I change it in a way that I get a mail from the subscriber's mail id itself instead of wordpress@mydomian.com.In other words that it fetch's and sends a mail from the subscribers email id instead of wp_mail. This is what I found in the plugin files -
/**
* [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,
A new user has subscribed through your Coming Soon page.
Subscriber's email: %s", $this->plugin_slug), $_POST['email'])
);
if($sent) {
print json_encode(array('status' => 'ok'));
die();
}
}
print json_encode(array('status' => 'error'));
die();
}
You can set the email $headers
, among which From
:
$headers = array();
$headers[] = 'From: ' . $_POST['email'] . ' <' . $_POST['email'] . '>';
$sent = wp_mail(
$to_email,
__( 'You have a new subscriber!', $this->plugin_slug ),
sprintf( __( "Hello,
A new user has subscribed through your Coming Soon page.
Subscriber's email: %s", $this->plugin_slug ), $_POST['email'] ),
$headers
);
Check the Codex.