...

View Full Version : Emailing Forms



adarshakb
10-30-2009, 05:42 PM
I learnt that i could email a form to myself using the mail() function but i get the following error. can any one please help?
thanks a lot in advance


Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\aduDocs\TestSite\form to mail.php on line 23


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="styles for content form.css" rel="stylesheet" type="text/css" />
</head>

<body>
<?php

if(array_key_exists('Submit',$_POST))
{
//code goes here
$to="adarshakb@gmail.com";
$name=$_POST['Name'];
$email=$_POST['EmailID'];
$comm=$_POST['Comments'];
$mail="Name:".$name."\nEmail:".$email."\nComments:\n".$comm;

echo "you submitted the array $mail";

mail($to,"WOOT",$mail,"Thanks");//$to,"WOOT",$mail);
}
?>
<form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<p>
<label for="Name">Name</label>
<input name="Name" type="text" id="Name" />
</label>
</p>
<p>
<label for="EmailID">Email ID:</label>
<input name="EmailID" type="text" id="EmailID" value="<?php echo isset($_POST['EmailID'])?$_POST['EmailID']:' '; ?>" />
</label>
</p>
<p>
<label for="Comments"></label>
</p>
<p></label>
<label for="textarea">Comments<br />
</label>
<textarea name="Comments" id="textarea" cols="60" rows="30"></textarea>
</p>
<p>
<label for="Submit">Submit</label>
<input type="submit" name="Submit" value="Submit" id="Submit" />
</p>
</form>
<p>&nbsp;</p>
</body>
</html>

adarshakb
10-30-2009, 06:00 PM
i corrected a mistake in the php.ini file i made while server configuration but now a new error

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:\aduDocs\TestSite\form to mail.php on line 23

but the content of my php.ini file on local system is

[mail function]
; For Win32 only.
SMTP = smtp.google.com
smtp_port = 25

; For Win32 only.
sendmail_from = adarshakb@gmail.com

adarshakb
10-30-2009, 06:05 PM
oops as some one pointed it to me.. changed the code to

[mail function]
; For Win32 only.
SMTP = smtp.gmail.com
smtp_port = 25

adarshakb
10-30-2009, 06:06 PM
but still the error comes
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:\aduDocs\TestSite\form to mail.php on line 23

adarshakb
10-30-2009, 06:24 PM
but it worked on the server.. i uploaded to http://www.caffinc.com/feedback.php

adarshakb
10-31-2009, 03:09 PM
noreply ? can any one solve the proble on my system?

godofreality
11-01-2009, 05:15 AM
not too sure but i think your local server has to be online for it to send out to the internet otherwise u r just working offline and nothing will be sent out but again i could be wrong



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum