What are the requirements for a working mail() function?<

liunx

Guest
I'm trying to code an email form for feedback on my site but I just get the "Error - send failed!".
Here is the code:

if ($origin=='submit_feedback'){
if(mail(<!-- e --><a href="mailto:'[email protected]">'[email protected]</a><!-- e -->',
'TITLE: Feedback',
$poster_name,
$poster_email,
$poster_comment))
{
echo("Thank you for your f eedback.<p>");
}
else{
echo("Error - send failed!<p>");
echo("Please try again later or send an email to the webmaster");
}
}
else{
echo("You have reached this page in error<p>");
}

The comparison of $origin is because there are different forms that can be sumbitted.

I also get an error if I try to send more than 5 fields. Is there a way around this?http://uk.php.net/manual/en/function.mail.php


your parameters are all wrong...

have a look at the article above, and ask more questions if you need to..I've read that. I don't think it is very clear though. I can see that I should add new headers but apart from that I cannot see anything wrong.

I did get it working once, somehow, and I got the data with the correct subject but everything else was just separated by line breaks since I hadn't defined the headers.

But now. . .it is clear...

what it should be:

mail($to, $subject, $message, $headers);


what you have is:

mail($to, $subject, $message, $more_message, $even_more_message);


or as you wrote it:

mail(<!-- e --><a href="mailto:'[email protected]">'[email protected]</a><!-- e -->', 'TITLE: Feedback', $poster_name, $poster_email, $poster_comment);

That's too many parameters for a start...

try:

$message = $poster_name ."\r\n" $poster_email ."\r\n". $poster_comment;
$headers = "From: <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->\r\nReply-To:[email protected]";

mail(<!-- e --><a href="mailto:'[email protected]">'[email protected]</a><!-- e -->', $subject, $message, $headers);Thanks Horus. It's all working now. :banana:no worries
 
Back
Top