HOw to send mail in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
syamswaroop
Forum Newbie
Posts: 19
Joined: Fri May 01, 2009 1:31 am

HOw to send mail in php

Post by syamswaroop »

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
User avatar
akuji36
Forum Contributor
Posts: 190
Joined: Tue Oct 14, 2008 9:53 am
Location: Hartford, Connecticut

Re: HOw to send mail in php

Post by akuji36 »

Should you be using post or get??

take a look at these links:(using POST)

http://www.buildwebsite4u.com/advanced/php.shtml

some reg ex is included = validation for your php

and this video tutorial on php email:

http://www.phpvideotutorials.com/lesson09/
Post Reply