...

View Full Version : Problem Sending email in php



anambd2006
03-01-2012, 07:40 AM
why the following email sending php form not working:

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("sayedbd2012@gmail.com", $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>";
}
?>

i made changes in php.ini file: smtp: 'my smtp server' port: 25

but mail not sending....

anybody can help me?

Anam

mlseim
03-01-2012, 12:24 PM
I don't know if my script below will be any different.
Try putting email() function in an "if" statement to allow PHP time to process it.



<?php

if (isset($_REQUEST['email'])){
//if "email" is filled out, send email

//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;

// send email
if(mail("sayedbd2012@gmail.com", $subject, $message, "From:" . $email)){
echo "Thank you for using our mail form";
exit;
}
else{
echo "Email did not send for some reason";
exit;
}
}
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>";
}
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum