Using PHP mail function on XAMPP
I know this question has been asked many times, but after going through everything, I still can't send emails from localhost. I tried to tweak my php.ini and sendmail.ini files, but it still doesn't work. I tried using smtp server ports 587 and 465 but none works.
I have added a screenshot of my .ini files. Please, help!
here is my php code:
<?php
$from="From: jain.ayusch10@gmail.com";
if(mail("gaganjain901@gmail.com", "Test Mail","THIS IS A TEST MAIL",$from)){
echo "success";
}else{
echo "faliure";
}
?>
source to share
Setting php.ini is not enough. You will need to install Mail Transport Agent
. For small projects, it is better to use an existing mail server SMTP
most of the time, as you need a lot of configuration to set up and configure the mail server, especially if you want to send HTML emails.
I recommend using PHPMailer or Swiftmailer for this purpose.
Also, if you have a hosting package, your ISP will most likely have a mail server installed and the mail function will work there. You just need to rethink your testing process.
source to share