PDA

View Full Version : php mailer



GrndMasterFlash
September 10th, 2008, 03:23 PM
i need a little help, i have this basic mail form, and in the to box goes the destination of who to send it to, but it's not sending....
anyways could anyone let me know what im doing wrong here:

<html>
<body>

<?php

if (isset($_REQUEST['to']))
{
$from = $_REQUEST['from'] ;
$to = $_REQUEST['to'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail($to, "Subject: $subject", $message, "From: from");
echo "Hey! Your message is on it's way! Your message will be displayed as fallows:<br />".$message;
}
else
{
echo "<form method='post' action='mailform.php'>
From: <input name='from' type='text' /><br />
To: <input name='to' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40' type='text/html'>
</textarea><br />
<input value='hit it!' type='submit' />
</form>";
}
?>

</body>
</html>

any help = greatly appericiated!

Templarian
September 10th, 2008, 04:25 PM
Made a lot of small changes don't know if it will work.

You forgot a $ on $from.

<html>
<body>

<?php

if (isset($_POST['to']))
{
$from = $_POST['from'];
$to = $_POST['to'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$headers = 'From: '.$from. "\r\n" .
'Reply-To: '.$from."\r\n".
'X-Mailer: PHP/' . phpversion();
mail($to, "Subject: ".$subject, $message, $headers);
echo "Hey! Your message is on it's way! Your message will be displayed as fallows:<br />".$message;
}
else
{
echo '<form method="post" action="mailform.php">
From: <input name="from" type="text" /><br />
To: <input name="to" type="text" /><br />
Subject: <input name="subject" type="text" /><br />
Message:<br />
<textarea name="message" rows="15" cols="40">
</textarea><br />
<input value="hit it!" type="submit" />
</form>';
}
?>

</body>
</html>

GrndMasterFlash
September 10th, 2008, 05:22 PM
thanks, i'll have to try it a little later, i just found out that our server doesn't support php mailing, so even if the code is right it woun't work untill i try it from a less secure server :P thank you for the pointers though, im sure it will come in handy!

Templarian
September 10th, 2008, 05:37 PM
If mail is disabled I believe all emails are written to mail.log or some kind of log file somewhere. The development server at my work has the same setup.

tfg
September 11th, 2008, 06:52 AM
if it still doesn't work, turn on error reporting with error_reporting(E_ALL); at the top of your script underneath the first