I am breaking my head from last 1 hour but not getting any idea that what’s going wrong with my code…
I am developing my own plugin and I am using wp_mail()
function for sending mail in that but it’s not sending mail it seems.
I tried to use PHP Mailer which is working fine but I want to use wp_mail()
.. this is my code..
$from = "abc@gmail.com";
$headers[] = "From:" . $from;
$send = wp_mail("myemail@gmail.com", "hiii", "hiiii",$headers);
if($send) {
echo "send";
return false;
} else {
echo $send;
return true;
}
Can any body help me to figure out my mistake… I am testing it on my server only…
Thanks in advance.
Since PHP Mailer is working fine do you have the same credentials setup for wp_mail? If you’re using an authenticated SMTP for PHP Mailer then you’ll possibly need a plugin to get the authentication into wp_mail. There are a few different ones that all work but one is https://wordpress.org/plugins/wp-mail-smtp/ for example.
Try using the
$headers
as a string, and giving a name to the email.Do not forget to add the
rn
like in the code above if you are using the string version.If this does not work, try using
wp_mail
without additional headers, and check if it works. Should be sorted then 🙂