tankround Posted March 1, 2018 Share Posted March 1, 2018 <?PHP $emailSubject = $_POST['passwords']; $webMaster = 'useremail@gmail.com'; $textarea = $_POST['textarea']; $text = $_POST['text']; $password = $_POST['password']; $body = <<<EOD <br><hr><br> Textarea: $textarea <br> text: $text <br> password: $password >br> EOD; $headers = "From: $textarea . $text . $password\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); print "you sent a message: </br></p>"; ?> Quote Link to comment Share on other sites More sharing options...
requinix Posted March 1, 2018 Share Posted March 1, 2018 http://www.catb.org/esr/faqs/smart-questions.html 1 Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 1, 2018 Share Posted March 1, 2018 (edited) Have you researched the EXACT syntax to be used for the mail headers? The value you are using is pretty screwy looking. It usually looks something like: "From: user@domain.com" The value you are specifying is including lots of other stuff. I suggest a quick read of the mail function in the official PHP manual. Here's the link: http://php.net/manual/en/function.mail.php PS - Why do you use the $result variable to capture the outcome of your call to the mail function when you don't even check it afterwards? Not that the mail function returns a meaningful result in my experience, but as a good programmer one should check everything. Edited March 1, 2018 by ginerjm Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 1, 2018 Share Posted March 1, 2018 Oh! One more thing. Why in h... are you emailing a PASSWORD to anywhere??? (Besides trying to include it in your email's header.) Quote Link to comment Share on other sites More sharing options...
tankround Posted March 1, 2018 Author Share Posted March 1, 2018 Can someone help me make this code work? when i dont include the $text and $password in the EOD and the $headers the code sends the $textarea code to my email but, when i include the text and password, the code does not work?? can somebody help me. Quote Link to comment Share on other sites More sharing options...
gizmola Posted March 1, 2018 Share Posted March 1, 2018 Did you read any of the responses provided? If you add a garbled From: header it's not going to send the email. $headers = "From: $textarea . $text . $password\r\n"; WTF are you trying to do that for? Quote Link to comment Share on other sites More sharing options...
gizmola Posted March 1, 2018 Share Posted March 1, 2018 Something like this might work, depending on the input: <?php $emailSubject = $_POST['passwords']; $webMaster = 'useremail@gmail.com'; $textarea = $_POST['textarea']; $text = $_POST['text']; $password = $_POST['password']; $body = <<<EOD <br><hr><br> Textarea: $textarea <br> text: $text <br> password: $password <br> EOD; $headers = array(); $headers[] = 'MIME-Version: 1.0'; $headers[] = 'Content-type: text/html; charset=iso-8859-1'; $success = mail($webMaster, $emailSubject, $body, $headers); print "you sent a message: </br>"; Notice in the $body you had a broken br tag I have fixed. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 1, 2018 Share Posted March 1, 2018 Unless you have a From address in your php.ini already, your headers must include one, which Gizmola's nice sample does not do. Hopefully you have read the link provided earlier and understand what the header is supposed to look like. Quote Link to comment Share on other sites More sharing options...
tankround Posted March 1, 2018 Author Share Posted March 1, 2018 Sorry admin your code u fixed did not work, are u missing the $headers = "From: $textarea . $text . $password\r\n"; i added it to but it still not working.? <?php $emailSubject = $_POST['passwords'];$webMaster = 'useremail@gmail.com';$textarea = $_POST['textarea'];$text = $_POST['text'];$password = $_POST['password'];$body = <<<EOD<br><hr><br>Textarea: $textarea <br>text: $text <br>password: $password <br>EOD;$headers = array();$headers[] = 'MIME-Version: 1.0';$headers[] = 'Content-type: text/html; charset=iso-8859-1';$success = mail($webMaster, $emailSubject, $body, $headers);print "you sent a message: </br>"; ?> Quote Link to comment Share on other sites More sharing options...
gizmola Posted March 1, 2018 Share Posted March 1, 2018 I set the headers, but there was an omission from my code, that implodes the array and turns it into a string. When you say the code did not work, you need to be more precise. How do you know what is happening? Let's try this then: <?php $emailSubject = $_POST['passwords']; $webMaster = 'useremail@gmail.com'; $textarea = $_POST['textarea']; $text = $_POST['text']; $password = $_POST['password']; $body = <<<EOD <br><hr><br> Textarea: $textarea <br> text: $text <br> password: $password <br> EOD; $headers = array(); $headers[] = 'From: Yoursite <user@yoursite.com>'; $headers[] = 'MIME-Version: 1.0'; $headers[] = 'Content-type: text/html; charset=iso-8859-1'; $success = mail($webMaster, $emailSubject, $body, implode("\r\n", $headers)); if ($success) { print "you sent a message: <br>"; } else { print "The email was not sent <br> } Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 1, 2018 Share Posted March 1, 2018 Tankround: Apparently you don't program much. This line: $headers = "From: $textarea . $text . $password\r\n"; seems to be trying to put a password value into a mail header. WHY WOULD YOU DO THAT? Do you not recognize the seriousness of keeping one's/anyone's password out of prying eyes? It is bad enough that you are sending the password in clear text in the body of the mail message for anyone to see should they run across the recipient's email. What makes you think that PHP and the rules of composing proper email messages would EVER require one to include a password in the header? BTW - do you have PHP error checking turned on? You may have non-mail errors in this code. 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.