Welcome to WebmasterWorld Guest from 50.17.114.227

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Problem with mail

mail() expects at most 5 parameters, 6 given in

     
3:57 pm on Sep 4, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 23, 2003
posts:76
votes: 0


Need some help with this. I have been researching the web, but all help seems to be related to a different set of circumstances.

Here is my code:

<?php
$to = "test@test.com";
$from = "From: contact-form@test.com\n";
mail($to, $_POST["contact-name"], $_POST["contact-email"], $_POST["contact-subject"], $_POST["contact-message"], $from);
?>

4:03 pm on Sept 4, 2004 (gmt 0)

Administrator

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
posts:15755
votes: 0


you have too many params in there

the format is like so
bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]])

so maybe this way
mail($to, $_POST["contact-subject"], $_POST["contact-message"], $from);

4:05 pm on Sept 4, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 23, 2003
posts:76
votes: 0


Thanks jatar,

would that not leave out some of the parameters though? Is there not a way to do it so I can include all of them?

4:16 pm on Sept 4, 2004 (gmt 0)

Administrator

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
posts:15755
votes: 0


well you could construct them differently, I use something like this

<?php
$to = $_POST["contact-email"];
$fromemail = "contact-form@test.com";

$headers .= "From: $fromemail\n";
$headers .= "X-Sender: $fromemail\n";
$headers .= "X-Mailer: PHP\n"; //mailer
$headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
$headers .= "Return-Path: $fromemail\n";
$headers .= "Reply-To: $fromemail\n";

$message = $_POST["contact-message"];
$subject = $_POST["contact-subject"];

mail($to, $subject, $message, $from);
?>

I don't know what you want to do with $_POST["contact-name"] but you could add that into the message maybe.