1 回答

TA贡献2021条经验 获得超8个赞
生成文件后,函数可以使用wp_mail函数发送它。
add_action( 'wpcf7_before_send_mail', 'CF7_pre_send' );
function CF7_pre_send($cf7) {
$output = "";
$output .= "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>Name: " . $_POST['your-name'];
$output .= "Email: " . $_POST['your-email'];
$output .= "Message: " . $_POST['your-message'];
file_put_contents( "cf7outputtest.xml", $output);
// then send email
$to = "sendto@example.com";
$subject = "The subject";
$body = "The email body content";
$headers = "From: My Name <myname@example.com>" . "\r\n";
$attachments = array( "cf7outputtest.xml" );
wp_mail( $to, $subject, $body, $headers, $attachments );
}
- 1 回答
- 0 关注
- 195 浏览
添加回答
举报