Jump to content

[SOLVED] sending mail bcc


ammar555

Recommended Posts

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

 

 

Link to comment
Share on other sites

...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  :confused:

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 !

Link to comment
Share on other sites

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 ;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!  :D

Link to comment
Share on other sites

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";

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.