wordpress 如何在wordpress中使用wp_mail()函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39890334/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 11:15:13 来源:igfitidea点击:
How to use wp_mail() function in wordpress
提问by Selva Kumar
<?php
if (isset($_POST['sbt'])) {
//user posted variables
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
//php mailer variables
$to = get_option('[email protected]');
$subject = "Report";
$headers = 'From: '. $email . "\r\n" .
'Reply-To: ' . $email . "\r\n";
echo "check";
//Here put your Validation and send mail
$sent = wp_mail($to, $subject, strip_tags($message), $headers);
if($sent) {
echo "sent";
}//mail sent!
else {
echo "failed";
}//message wasn't sent
}
?>
I have developed a own word press site i need to use WP_mail() function to my contact form.
我开发了一个自己的文字新闻网站,我需要在我的联系表格中使用 WP_mail() 函数。
please help me.
请帮我。
回答by JanuszO
this is example:
这是示例:
//user posted variables
$name = $_POST['message_name'];
$email = $_POST['message_email'];
$message = $_POST['message_text'];
//php mailer variables
$to = get_option('admin_email');
$subject = "Some text in subject...";
$headers = 'From: '. $email . "\r\n" .
'Reply-To: ' . $email . "\r\n";
}
//Here put your Validation and send mail
$sent = wp_mail($to, $subject, strip_tags($message), $headers);
if($sent) {
}//message sent!
else {
}//message wasn't sent
回答by Nishant
Please view function documentation at https://developer.wordpress.org/reference/functions/wp_mail/
请在https://developer.wordpress.org/reference/functions/wp_mail/查看功能文档