YousefDiab Posted August 20, 2014 Share Posted August 20, 2014 <?php $site_email = $row["[email protected]"]; $email25=$_REQUEST['email']; $action=$_REQUEST['action']; if ($action=="") /* display the contact form */ { ?> <form id="ContactForm" action="" method="POST" enctype="multipart/form-data"> <input type="hidden" name="action" value="submit"> <div> <div class="wrapper"> <span>Your Name:</span> <input type="text" class="input" name="name" maxlenght="15"> </div> <div class="wrapper"> <span>Your E-mail:</span> <input type="text" class="input" name="email" > </div> <div class="textarea_box"> <span>Your Message:</span> <textarea name="textarea" cols="1" rows="1"></textarea> </div> <input type="submit" class="button1"> <a href="contact.php" class="button1">Clear</a> </div> </form> <?php } else /* send the submitted data */ { $name=$_REQUEST['name']; $email=$_REQUEST['email']; $message=$_REQUEST['textarea']; if (($name=="")||($email=="")||($message=="")) { echo "All fields are required, please fill <a href=\"\">the form</a> again."; } else{ $from="From: $name<$email>\r\nReturn-path: $email"; $subject= $subject1; mail($to =$site_email, $message, $from); echo " <div class=\"contactform\"> Thank you for contacting us, please wait for our reply! </div> "; } } ?> The only problem is that im not recieving the email :/ Any Help ? I would really appreciate it and thank you Link to comment https://forums.phpfreaks.com/topic/290549-php-mail-not-sending/ Share on other sites More sharing options...
ginerjm Posted August 20, 2014 Share Posted August 20, 2014 your mail statement has an error in it? Link to comment https://forums.phpfreaks.com/topic/290549-php-mail-not-sending/#findComment-1488401 Share on other sites More sharing options...
BuildMyWeb Posted August 20, 2014 Share Posted August 20, 2014 try something more like the below else { $from = "From: $name<$email>\r\nReturn-path: $email"; $subject = "Form Submission"; $to = "[email protected]"; $message = "you likely will want to loop through your $_POST variables here"; mail($to, $subject, $message); echo" <div class=\"contactform\"> Thank you for contacting us, please wait for our reply! </div> "; } there is also an option fourth parameter in the mail() function. preferable to use it well if you dont want your emails being dropped in spam folders, blocked, etc. Link to comment https://forums.phpfreaks.com/topic/290549-php-mail-not-sending/#findComment-1488432 Share on other sites More sharing options...
AP_King7 Posted August 20, 2014 Share Posted August 20, 2014 How do you loop through POST variables there? Link to comment https://forums.phpfreaks.com/topic/290549-php-mail-not-sending/#findComment-1488442 Share on other sites More sharing options...
AP_King7 Posted August 20, 2014 Share Posted August 20, 2014 For instance how would I put this into $message? <?php $aMeat = $_POST['tMeat']; if(empty($aMeat)) { echo("You didn't select any meats."); } else { $N = count($aMeat); echo("You ordered $N meat(s): "); for($i=0; $i < $N; $i++) { echo($aMeat[$i] . " - ").; } } ?> Link to comment https://forums.phpfreaks.com/topic/290549-php-mail-not-sending/#findComment-1488443 Share on other sites More sharing options...
CroNiX Posted August 20, 2014 Share Posted August 20, 2014 Problem is you're echoing the values, which will just go out to the browser. You want to add it to a string. $aMeat = $_POST['tMeat']; $message = ''; if(empty($aMeat)) { $message = "You didn't select any meats."; } else { $N = count($aMeat); $message = "You ordered $N meat(s): "; for($i=0; $i < $N; $i++) { //add this meat to the end of the $message string (string concatenation) $message .= $aMeat[$i] . " - "; } } Link to comment https://forums.phpfreaks.com/topic/290549-php-mail-not-sending/#findComment-1488445 Share on other sites More sharing options...
CroNiX Posted August 20, 2014 Share Posted August 20, 2014 alternatively, since $aMeat is an array, you can use implode() on it, like $N = count($aMeat); $message = "You ordered $N meat(s): " . implode(', ', $aMeat); Message would now be something like: You ordered 1 meat(s): pork or if there were more than one selected: You ordered 3 meat(s): pork, beef, chicken Link to comment https://forums.phpfreaks.com/topic/290549-php-mail-not-sending/#findComment-1488446 Share on other sites More sharing options...
AP_King7 Posted August 20, 2014 Share Posted August 20, 2014 I need all of the information to go into the browser as well. I have it all set up to echo to the browser and it works perfectly, now I just need to send all of the different arrays in an e-mail message. How do I echo them to the browser and add them to my message? Also, I am wanting to add more than just meats, I have other variables similar to $aMeat that I want to add in the message, is that possible this way? Link to comment https://forums.phpfreaks.com/topic/290549-php-mail-not-sending/#findComment-1488448 Share on other sites More sharing options...
BuildMyWeb Posted August 20, 2014 Share Posted August 20, 2014 $name = $_POST['name']; $email = $_POST['email']; $to = "[email protected]"; $subject = "submission data"; $fields = array(); $fields["Name"] = $name; $fields["Email"] = $email; $message = "We have received the following information from a submission:\n\n"; foreach($fields as $a => $b) { $message .= sprintf("%30s: %s\n",$a,$b); } mail($to, $subject, $message); Link to comment https://forums.phpfreaks.com/topic/290549-php-mail-not-sending/#findComment-1488449 Share on other sites More sharing options...
ginerjm Posted August 20, 2014 Share Posted August 20, 2014 I do believe that the mail function requires the headers to be in the 4th (missing) parameter. For one thing you absolutely have to provide a from address there. Link to comment https://forums.phpfreaks.com/topic/290549-php-mail-not-sending/#findComment-1488452 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.