Php function mail () not working

I used the mail () function in php encoding but I was not able to send any mail. Before continuing, I want to clarify the context for using the mail () function.

I did not host my site so that it was on localhost. I set smtp, sendmail_path port, etc.

After a lot of searching, it seems to me that I need to download the mail server. I downloaded the free sendmail server and configured it as the intended site. However, all in vain, someone told me that I can not use the mail function until I host my site not only on localhost. Please guide me.

<?php
   $from = "oooo@hotmail.com"; // sender
   $subject = " My cron is working";
   $message = "My first Cron  :)";

   // message lines should not exceed 70 characters (PHP rule), so wrap it

   $message = wordwrap($message, 70);

   // send mail

   ini_set("SMTP","localhost");
   ini_set("smtp_port","25");
   ini_set("sendmail_from","00000@gmail.com");
   ini_set("sendmail_path", "C:\wamp\bin\sendmail.exe -t");

   mail("jXXXXXX@gmail.com",$subject,$message,"From: $from\n");

   echo "Thank you for sending us feedback";

?>

this sendmail configuration file:

smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=auto

;default_domain=domain.com
auth_username=jxxxx@gmail.com
auth_password=8888

force_sender=j*****@gmail.com

( ! ) SCREAM: Error suppression ignored for
( ! ) Warning: mail() [<a href='function.mail'>function.mail</a>]: Failed to connect to      mailserver at &quot;localhost&quot; port 25, verify your &quot;SMTP&quot; and &quot;smtp_port&quot;    setting in php.ini or use ini_set() in C:\wamp\www\test.php on line 20
+3
source share
1 answer

I think you are not set up properly

XAMPP, localhost.

, C:\xampp\php\php.ini c:\xampp\sendmail\sendmail.ini gmail.

C:\xampp\php\php.ini extension=php_openssl.dll , SSL gmail localhost.

php.ini [mail function]

SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = my-gmail-id@gmail.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

c:\xampp\sendmail\sendmail.ini. sendmail.ini

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=my-gmail-id@gmail.com
auth_password=my-gmail-password
force_sender=my-gmail-id@gmail.com

! php localhost.

, ​​ SSL ( "openssl" phpinfo()).

PHP.ini:

ini_set("SMTP","ssl://smtp.gmail.com");
ini_set("smtp_port","465");
+12

All Articles