View Full Version : seding email thruogh php

08-11-2009, 06:50 AM
iam getting this warning when iam submiting my form

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 C:\wamp\www\project\post3.php on line 40

Message delivery failed...

and my code is

$to = "hema@gmail.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");


acually i got this code from google,if ur having the better one please help me

08-11-2009, 08:07 AM
As a simple starter mailer that is ok, I tend to add another variable like so,

$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" ;

mail($to, $subject, $body, $headers);

However, your problem seems more to do with PHP not being able to open the port assigned to SMTP.

Have a look at this link, http://www.php.net/manual/en/ref.mail.php

08-11-2009, 02:23 PM
Seeing as you're probably new to the mail function, I advise you to contact your webhost. If you're running it on your own server, SMTP may not be properly configured, or not work at all.

08-13-2009, 06:46 AM
thank u