首页 > 解决方案 > 自动回复功能与显示名称而不是电子邮件的电子邮件标题一起使用

问题描述

我得到了这个代码。但是由于尝试包含标题,我不再收到电子邮件。我得到了 PHP 7.4 版

#hook in to wpcf7_mail_sent - this will happen after form is submitted
add_action( 'wpcf7_mail_sent', 'contact_form_autoresponders' ); 

#our autoresponders function
function contact_form_autoresponders( $contact_form ) {

    if( $contact_form->id==14383 ){

        #retrieve the details of the form/post
        $submission = WPCF7_Submission::get_instance();
        $posted_data = $submission->get_posted_data();
  
        $headers = 'From: "Name Lastname" <myemail@mail.com>' . "\r\n" . 
          'Reply-To: "Name Lastname" <myemail@mail.com>' . "\r\n" .
          'X-Mailer: PHP/' . phpversion();

        #set autoresponders based on dropdown choice            
        switch( $posted_data['states'] ){
            case 'California':
            $msg="California email body goes here";
            break;

            case 'Texas':
            $msg="Texas email body goes here";
            break;

        }

        #mail it to them
        mail( $posted_data['email'], 'Thanks for your enquiry', $msg, $headers);
    }
}

怎么了!?

标签: phpemailheaderauto

解决方案


推荐阅读