2014-12-07 2 views
0

플러그인을 사용하여 WordPress의 방문 페이지를 설정하려고합니다. - 곧 제공 될 예정입니다. 구독 상자가 있습니다. 누군가가 회보에 가입 할 때마다 나는 통지와 함께 [email protected]으로부터 이메일을받습니다. 어떻게하면 구독자의 메일 아이디 자체에서 [email protected] 대신 메일을받는 방식으로 변경할 수 있습니다. 즉, wp_mail 대신 구독자 이메일 아이디에서 메일을 가져 와서 보냅니다. 이 내가 플러그인 파일에있는 것입니다 -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(); 
} 

답변

0

당신은 어떤 From 중 이메일 $headers, 설정할 수 있습니다

$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를 확인합니다.

+0

안녕하세요 diggy, 답장을 보내 주셔서 감사합니다. 죄송합니다. 코딩에 약간의 새로운 기능이 있습니다. 구독자의 이메일 ID 자체를 가져올 수 있도록 '보낸 사람'에 정확하게 입력해야하는 내용을 알려주십시오. – Abhilash

+0

답변이 업데이트되었습니다. – diggy

관련 문제