I am new to PHP and I’m using the mail function to send emails which is not working. I get a success message, but still it does not work
same code
<?php
$email_to = "abc@abc.com";
$email_subject = "Test mail";
$email_body = "Hello! This is a simple email message.";
if(mail($email_to, $email_subject, $email_body)){
echo "The email($email_subject) was successfully sent.";
} else {
echo "The email($email_subject) was NOT sent.";
}
?>
Am I missing anything, do I need to include any files for this function.. I am from asp.net & this is the basic script which found on website.
I tried other scripts related to mail they didn’t work either..
I AM RUNNING THIS SCRIPT ON THE WEBSITE NOT on the localhost
This is probably a configuration error. If you insist on using PHP
mailfunction, you will have to editphp.ini.If you are looking for an easier and more versatile option (in my opinion), you should use PHPMailer.