Home C C++ Java Python Perl PHP SQL JavaScript Linux Online Test Forum

Home » Forum » x-Forum » Question

How to send email using php mail function and what are the php.ini settings needed?

Hi, I'm new to PHP. I need to send email without providing any password in settings. First of all is this possible? If possible, what are the settings needed to be done in php.ini and in any other settings required? I have my php script as below :


<?php
ini_set("SMTP","ssl://smtp.gmail.com");
ini_set("smtp_port","587");
$to_email = 'vidhyajsv@gmail.com';
$subject = 'Testing PHP Mail';
$message = 'This mail is sent using the PHP mail function';
$headers = 'From: vidhyajsv@gmai\r\n';
$headers .="Content-type: text/html\r\n";
mail($to_email,$subject,$message,$headers);
?>
And im getting below error when I execute php script. Warning: mail(): Failed to connect to mailserver at "ssl://smtp.gmail.com" port 587, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp64\www\emailapp\index.php on line 18. Please help me on this.

Posted by vidhya 2019-07-19 06:01:10

No Ans Posted

Please login to comment

Log In


Ask New Question