HOw to send mail in php
Posted: Wed Aug 26, 2009 1:26 am
I am using php5 and apache2 on windowsxp profesional
<html>
<body>
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("syam.swaroop@stsresearch.co.in", "Subject: $subject",
$message, "From: $email" );
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
?>
</body>
</html>
My php.ini settigs are like this
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
;sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
// I got this error when i run the above Php code
Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for syam.swaroop@stsresearch.co.in in C:\Apache2.2\htdocs\DiscoverGuru\DG_v2_17-AUG-2009\sample.php on line 89
Thank you for using our mail form
Please help everyone tells its very easy to send mail but iam getting this error
<html>
<body>
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("syam.swaroop@stsresearch.co.in", "Subject: $subject",
$message, "From: $email" );
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
?>
</body>
</html>
My php.ini settigs are like this
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
;sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
// I got this error when i run the above Php code
Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for syam.swaroop@stsresearch.co.in in C:\Apache2.2\htdocs\DiscoverGuru\DG_v2_17-AUG-2009\sample.php on line 89
Thank you for using our mail form
Please help everyone tells its very easy to send mail but iam getting this error