atticus Posted March 13, 2008 Share Posted March 13, 2008 Alright, the mail() is working fine until I add more than five input fields to be sent. The error I received said that php imposes a limit of five for the mail() function. My solution was to create a string of the information and just send the string. However, I think I have the syntax wrong. Any suggestions would be great, thanks. <?php $email = $HTTP_POST_VARS['email']; $subject = $HTTP_POST_VARS['subject']; $message = $HTTP_POST_VARS['message']; $customeremail = $HTTP_POST_VARS['customeremail']; $address1 = $HTTP_POST_VARS['address1']; $address2 = $HTTP_POST_VARS['address2']; $city = $HTTP_POST_VARS['city']; $state = $HTTP_POST_VARS['state']; $zip = $HTTP_POST_VARS['zip']; $content = $address1 $address2 $city $state $zip; ... elseif (mail($email,$subject,$customeremail,$message, $content )) { Quote Link to comment Share on other sites More sharing options...
soycharliente Posted March 13, 2008 Share Posted March 13, 2008 This is what I use: <?php foreach ($_POST as $key => $val) { $_POST[$key] = stripslashes($val); } $to = "address@domain.tld"; // me $subject = "Your mom."; $name = $_POST['name']; $email = $_POST['email']; $msg = $_POST['message']; // make it look like it's coming from you so it's easier to reply $headers .= "From: " . $name . "<" . $email . ">\r\n"; ini_set(sendmail_from, $email); mail($to, $subject, $msg, $headers); ini_restore(sendmail_from); ?> In your code, your $content is just a bunch of variables typed after it. What are you trying to accomplish there? Are you trying to append them together? Because you're not. You need to use the . method. $content = $var1 . $var2 . $var3; And even then it would turnout like this: $var1 = "Hello"; $var2 = "World"; $var3 = "!"; $content = $var1 . $var2 . $var3; // HelloWorld! And your variables are in the wrong order. mail($to, $subject, $message, $headers) In your use, you've got the to field and the subject field right. But then for the message you have the customer's email. Then for the headers you have the message. You need to RTM about how mail takes in parameters a bit. Quote Link to comment Share on other sites More sharing options...
atticus Posted March 13, 2008 Author Share Posted March 13, 2008 thanks for the script, however I am still having a problem. How do I include multiple fields into the message section. For example, I would like to include info from the input fields of the form such as address and phone. This is how I tried it, but for some reason its just not working. <?php foreach ($_POST as $key => $val) { $_POST[$key] = stripslashes($val); } $to = "jcapshaw@gmail.com"; // me $subject = $_POST['subject']; $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $phone = $_POST['phone']; [color=red]$msg = $message . $phone;[/color] // make it look like it's coming from you so it's easier to reply $headers .= "From: " . $name . "<" . $email . ">\r\n"; ini_set(sendmail_from, $email); mail($to, $subject, $msg, $headers); ini_restore(sendmail_from); Quote Link to comment Share on other sites More sharing options...
soycharliente Posted March 13, 2008 Share Posted March 13, 2008 <?php foreach ($_POST as $key => $val) { $_POST[$key] = stripslashes($val); } $to = "jcapshaw@gmail.com"; // me $subject = $_POST['subject']; $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $phone = $_POST['phone']; $msg = "This is a message from the website! The message is as follows: $message The phone number of the person that sent this to you is: $phone"; // make it look like it's coming from you so it's easier to reply $headers .= "From: " . $name . "<" . $email . ">\r\n"; ini_set(sendmail_from, $email); mail($to, $subject, $msg, $headers); ini_restore(sendmail_from); Something like that? Quote Link to comment Share on other sites More sharing options...
atticus Posted March 13, 2008 Author Share Posted March 13, 2008 thanks, works great. You really cleared up the way it works. php.net's explanation on mail() has very little information. Thanks again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.