如何在wordpress

时间:2016-10-06 07:43:43

标签: wordpress wordpress-theming custom-wordpress-pages wordpress-thesis-theme



<?php
if (isset($_POST['sbt'])) {
//user posted variables
  $name = $_POST['name'];
  $email = $_POST['email'];
  $message = $_POST['message'];

//php mailer variables
  $to = get_option('aaaa@gmail.com');
  $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
}
?>
&#13;
&#13;
&#13;

我已经开发了一个自己的单词新闻网站,我需要在我的联系表格中使用WP_mail()函数。

请帮帮我。

2 个答案:

答案 0 :(得分:2)

这是一个例子:

//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

答案 1 :(得分:0)