I'm trying to make a php form which sends a gmail email to someone through php form.
I expected the gmail to arrive, because I typed in the mail($to,$userSubject,$body);
It didn't work, however. I'm using visual studio code's php live server extension, because I just couldn't set it up with xampp control panel.
Some code:
$userName = $_POST['name'];
$userEmail = $_POST['email'];
$userSubject = $_POST['subject'];
$message = $_POST['message'];
$to = "example@gmail.com";
$body = "";
$body .= "From: ".$userName. "\r\n";
$body .= "Email: ".$userEmail. "\r\n";
$body .= "Message: ".$message. "\r\n";
When I run the code from the form I get an error message:
Warning: mail(): Failed to connect to mailserver at "smpt.gmail.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Users\Acer\Desktop\kenefagijnica\webform.php on line 31
I tried to use ini_set(), but I don't know what parameters to use to change the port so that I am able to send gmails.
I also tried looking at the php.ini file but I don't know what to do for the Mailer.
Help, anyone?