Welcome to WebmasterWorld Guest from 54.159.250.110

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)

10+ Year Member



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 Sep 4, 2004 (gmt 0)

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



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 Sep 4, 2004 (gmt 0)

10+ Year Member



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 Sep 4, 2004 (gmt 0)

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



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.