homepage Welcome to WebmasterWorld Guest from 54.224.179.98
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Problem with mail
mail() expects at most 5 parameters, 6 given in
Daily Sparring




msg:1271239
 3:57 pm on Sep 4, 2004 (gmt 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);
?>

 

jatar_k




msg:1271240
 4:03 pm on Sep 4, 2004 (gmt 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);

Daily Sparring




msg:1271241
 4:05 pm on Sep 4, 2004 (gmt 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?

jatar_k




msg:1271242
 4:16 pm on Sep 4, 2004 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved