WordpressWordpress Tricks

Send Email in WordPress working example

wordpress cheat code to update User Password mysql query
186Views

Hello to all, welcome to therichpost.com. In this post, I will show you, Send Email in WordPress working example.

If you are new in WordPress, then you can check my old WordPress post and WordPress tricks to get some knowledge of WordPress.

I personally like wordpress very much and I do my mostly work in WordPress.

Here is the working code for Send Email in WordPress working example and please follow it carefully:

<?php
   //Mail Function
   $to        = 'YourEmailId.com';
   $subject   = "Wordpress Test Email";
   $headers   = 'Content-type: text/html;charset=utf-8' . "\r\n".'From: '. $_POST['request_email'] . "\r\n" .
   'Reply-To: ' . $_POST['request_email'] . "\r\n";
   
   $message = "Name = ".$_POST['request_name'];
   $message .= "<br />Phone =".$_POST['request_phone'];
   $message .= "<br />Email =".$_POST['request_email'];
   $message .= "<br />Comment =".$_POST['request_comment'];
   
  //Here put your Validation and send mail
   $sent = wp_mail($to, $subject, $message, $headers);
     if($sent) {
       echo "Mail Sent";
     }
     else  {
       echo "Mail did not send";
   }       
 ?>

 

If you have any query related to this post then please do comment below.

Harjas,

Thank you

Ajay Malhotra
the authorAjay Malhotra
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am full stack developer. I love coding. I know Wordpress, Core php, Angularjs, Angular 2, Angular 6, Angular 7, laravel, Codeigniter, Shopify, Squarespace, Jquery, Google Map Api, Vuejs, Reactjs, Bigcommerce etc.

Leave a Reply

Positive SSL