ammar555 Posted July 25, 2009 Share Posted July 25, 2009 Hi guys, Well i would like to say i have very limited knowledge about php, "Just started learning." however here is what i want to make. I'm able to send mail to my e-mail, but i want to include bcc. i created a textfiled and named it bcc. Now when i open the page it sends an e-mail successfuly but the bcc is not working. it only sends to $to (whatever e-mail i put) , but the $bcc (won't send). Is it maybe i wrote it wrong. Where did i make my mistake? here is my code <form method="post" action="SimpleEmail.php"> Email: <textarea name="bcc" id="bcc">BCC-Email@yahoo.com</textarea> <br> <br> <input type="submit"> </form> <?php $to = "My-Email@yahoo.com"; $subject = "Test"; $message = ' <html> <head> <title>Birthday Reminders for August</title> </head> <body> <p>Here are the birthdays upcoming in August!</p> <table> <tr> <th>Person</th><th>Day</th><th>Month</th><th>Year</th> </tr> <tr> <td>Joe</td><td>3rd</td><td>August</td><td>1970</td> </tr> <tr> <td>Sally</td><td>17th</td><td>August</td><td>1973</td> </tr> </table> </body> </html> '; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "Reply-To: My-Email@yahoo.com\r\n"; $headers .= "Return-Path: My-Email@yahoo.com\r\n"; $headers .= 'From: My Name <MY-Email@yahoo.com>' . "\r\n"; $headers .= 'Bcc: $bcc' ."\r\n"; $sent = mail($to, $subject, $message, $headers) ; if($sent) {print "Your mail was sent successfully"; } else {print "We encountered an error sending your mail"; } ?> this is the bcc code $headers .= 'Bcc: $bcc' ."\r\n"; and this is the textfiled i have on my page <textarea name="bcc" id="bcc">BCC-Email@yahoo.com</textarea> so where did i make my mistake Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted July 25, 2009 Share Posted July 25, 2009 You will have to do $_POST['bcc'] instead. Quote Link to comment Share on other sites More sharing options...
ammar555 Posted July 25, 2009 Author Share Posted July 25, 2009 You will have to do $_POST['bcc'] instead. you mean i change this $headers .= 'Bcc: $bcc' ."\r\n"; to $headers .= 'Bcc: $_POST['bcc']' ."\r\n"; Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted July 25, 2009 Share Posted July 25, 2009 http://php.net/manual/en/language.types.string.php Quote Link to comment Share on other sites More sharing options...
ammar555 Posted July 25, 2009 Author Share Posted July 25, 2009 http://php.net/manual/en/language.types.string.php oh okay thank you, i will see where i made my mistake. i know it has to do with strings and something like that. Searching for my error... Even though i wanted straight answer Thanks, Quote Link to comment Share on other sites More sharing options...
.josh Posted July 25, 2009 Share Posted July 25, 2009 ...as in, you wanted an explanation to be posted directly in the thread, instead of having to follow a link to find out? Quote Link to comment Share on other sites More sharing options...
ammar555 Posted July 25, 2009 Author Share Posted July 25, 2009 ...as in, you wanted an explanation to be posted directly in the thread, instead of having to follow a link to find out? i'm sorry since that time i been trying and kept failing as i told you before i am just beginner, so please would you explain a little more. Maybe from you i will understand better, the website has too much things. what did you mean when you said You will have to do $_POST['bcc'] instead. Thanks again and i appreciate you time ! Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted July 25, 2009 Share Posted July 25, 2009 Use this: $bcc = $_POST['bcc']; It is variable holding data from a form with POST. Quote Link to comment Share on other sites More sharing options...
ammar555 Posted July 25, 2009 Author Share Posted July 25, 2009 Use this: $bcc = $_POST['bcc']; It is variable holding data from a form with POST. This is what i understood. I change this $headers .='Bcc: $bcc' ."\r\n"; To this $bcc = $_POST['bcc']; Right! ;D And What do i change here $sent = mail($to, $subject, $message, $headers) ; do i keep it the same, because it didn't send a bcc it only sends one e-mail to $to I hope I am not given you a hard time! Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted July 25, 2009 Share Posted July 25, 2009 If you read the page I linked to you would find out that variable interpolation only works with double quoted strings. You would also find out what variable interpolation is. Quote Link to comment Share on other sites More sharing options...
.josh Posted July 25, 2009 Share Posted July 25, 2009 If you want to understand what is going on (and therefore what is going wrong), you need to make a more concerted effort on your part. I think you should probably step back and learn basic php syntax, because you seem to be struggling with basic syntax issues. Your mail function is still not sending to anybody else because you removed $headers, which is what you are using in your mail function. $bcc = $_POST['bcc']; $headers .='Bcc: ' . $bcc ."\r\n"; Quote Link to comment Share on other sites More sharing options...
ammar555 Posted July 25, 2009 Author Share Posted July 25, 2009 If you want to understand what is going on (and therefore what is going wrong), you need to make a more concerted effort on your part. I think you should probably step back and learn basic php syntax, because you seem to be struggling with basic syntax issues. Your mail function is still not sending to anybody else because you removed $headers, which is what you are using in your mail function. $bcc = $_POST['bcc']; $headers .='Bcc: ' . $bcc ."\r\n"; THANK YOUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU VERY MUCH. 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.