-2

this is my template code and it is not sending mails to customers in wordpress. please anyone help me to make right this code. thanks

<?php
/*
Template name: contact
*/
get_header(); 
$email="test@gmail.com";
$subject="testing";
$message = "hi this is test";
$headers = 'From:' . "testing@gmail.com";

if(wp_mail($email, $subject, $message, $headers))
{
echo "sending mail test";
}
else
{
     echo "not";
}

get_footer();
?>
Vishal
  • 109
  • 1
  • 4
  • 11
  • Do you have access to the php log file? [How to find log file](https://stackoverflow.com/questions/5127838/where-does-php-store-the-error-log-php5-apache-fastcgi-cpanel) – Haydn Dias Jun 22 '17 at 09:01

3 Answers3

3

Try to set header

$headers[] = 'Content-type: text/plain; charset=utf-8';
$headers[] = 'From:' . "testing@gmail.com";

or

It can be problem with your server (hosting)

0

This is because of you are not using php's standard mail function. This plugin will help you. WP mail SMTP

Select "Use PHP mail function to send the emails" from options on settings page and check the emails.

Ahmed Ginani
  • 6,522
  • 2
  • 15
  • 33
-1

I checked the script and it working. Maybe you have problams on server.

to.shi
  • 94
  • 3