3

I know this question has been asked many times but after going through all of them i am still not able to send mails from localhost. I have tried configuring my php.ini and sendmail.ini files but it still doesn't work. I tried using smtp server ports 587 and 465 but none seem to work.

I have attached the screenshot of my .ini files. Please Help!

php.ini

sendmail.ini

sendmail.ini continued

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";
    }

   ?>
Gerald Schneider
  • 17,416
  • 9
  • 60
  • 78
Ayusch
  • 417
  • 7
  • 17

2 Answers2

0

You must try PHPMailer

PHPMailer - A full-featured email creation and transfer class for PHP

Here

Awais Tahir
  • 180
  • 1
  • 10
0

Setting up the php.ini is not enough. You would have to set up an Mail Transport Agent. For small projects it is better to use an existing mail sever over SMTP most of the time, since installing and configuring the mail server yourself will require lots of configuration, especially if you want to send HTML emails.

I recommend using PHPMailer or Swiftmailer for that purpose.

Other than that, if you have a hosting package your provider will most likely have a mail server installed and the mail function will work there. You just have to rethink the testing process.

oshell
  • 8,923
  • 1
  • 29
  • 47