WordpressWordpress Tricks

Send Email in WordPress working example

Wordpress send pdf with wp_mail function

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:

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


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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Positive SSL