Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use wp_mail() function in wordpress [closed]

<?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.

please help me.

like image 532
Selva Kumar Avatar asked Oct 06 '16 07:10

Selva Kumar


1 Answers

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
like image 122
JanuszO Avatar answered Sep 28 '22 01:09

JanuszO