Sending mail with PHP
Posted: Mon Mar 18, 2013 6:46 am
Hi there, I am a newby PHP programmer and have only been using it for roughly 2 weeks now,
I have created a contact us page for a project that I am currently doing, (this is not to be used commercially so I have no need for validation although I am aware of its importance). Anyway every time I try to send the E-mail I am getting the response
"Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in G:\phpServer\xampplite\htdocs\Project_Design(Unit4)\Php\comments.php on line 9
Error!"
I am aware of needing to change something within the PHP.ini mail function but i have no idea what to change or what to change anything too. Underneath is the PHP code that I am using to send the mail (For this purpose i have removed my current email of where i wish the email to be sent too although the provider is still google.
PHP Code
Any help on this matter will be greatly appreciated. Thanks in advance!
I have created a contact us page for a project that I am currently doing, (this is not to be used commercially so I have no need for validation although I am aware of its importance). Anyway every time I try to send the E-mail I am getting the response
"Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in G:\phpServer\xampplite\htdocs\Project_Design(Unit4)\Php\comments.php on line 9
Error!"
I am aware of needing to change something within the PHP.ini mail function but i have no idea what to change or what to change anything too. Underneath is the PHP code that I am using to send the mail (For this purpose i have removed my current email of where i wish the email to be sent too although the provider is still google.
PHP Code
Code: Select all
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$recipient = "myemail@gmail.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>