Solved

How to add a bcc to this script?

Posted on 2004-04-08
8
346 Views
Last Modified: 2008-02-07
Hi!

I'm using this "recommend this site" script, http://portfolio.toefur.com/www/recommend_php and I'd like to see who is using this script: I'd like to get a bcc email sent to my personal email address with the info of sender, receiver and text used.
Do you have any ideas how to modify this script that way?

Greetings,

su-n
0
Comment
Question by:su-n
  • 3
  • 3
  • 2
8 Comments
 
LVL 8

Assisted Solution

by:CoolATIGuy
CoolATIGuy earned 125 total points
ID: 10788879
Well, we're going to go into the "if you do not know much about php you should not change any of the following lines" section. :-)


/// if you do not know much about php you should not change any of the following lines.......
if ($var=="tak"){


      $nota = nl2br($nota);
      $nota = eregi_replace("<br>","\n",$nota);
      $nota = eregi_replace("<br />","\n",$nota);


      $mailTo="$email2";


!!!CHANGE THIS LINE:      $mailHeaders="From:$email1 \nReply-To:$email1";
!!!INTO THIS LINE: $mailHeaders="From:$email1 \nReply-To:$email1 \nCc: $CARBONCOPYEMAILVARIABLE";


            if ($imie) {
            $mailSubject="$imie $subimie";
            } else {
            $mailSubject=$noimie;
            }

            if ($nota)
            {
            $mailBody="$nota<br>$imie\nLink: $adreswww";
            } else {
            $mailBody="$autonota\n$imie\nLink: $adreswww";
            }

$mailBody = eregi_replace("<br>","\n",$mailBody);

///////wysyla maila do adresata /////////
mail($mailTo, $mailSubject, $mailBody, $mailHeaders);


That should do it...


CoolATIGuy
0
 
LVL 1

Author Comment

by:su-n
ID: 10789854
Hi!

Thanks a lot, it's working.
But hot to make the Cc a Bcc?
I already tried to make
$mailHeaders="From:$email1 \nReply-To:$email1 \nCc: $CARBONCOPYEMAILVARIABLE";
to
$mailHeaders="From:$email1 \nReply-To:$email1 \nBcc: $CARBONCOPYEMAILVARIABLE";

but that's not working.

Greetings,

su-n
0
 
LVL 1

Expert Comment

by:sophomore
ID: 10791850
What version of PHP are you running? On what system? I don't think PHP's mail() function supports the BCC header on PHP versions < 4.3.0 running on Windows systems.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Expert Comment

by:sophomore
ID: 10791887
You know, you could just add another call to the mail() function:

mail($mailTo, $mailSubject, $mailBody, $mailHeaders);
mail('your-bcc-email-address@youdomain.tld', $mailSubject, $mailBody, $mailHeaders);

That way, the original recipient receives the email and so do you, but the original recipient will not see your email address in the TO or CC headers.

0
 
LVL 1

Accepted Solution

by:
sophomore earned 125 total points
ID: 10791927
One last thing: PHP recommends that in your "Additional Email Headers" argument of the mail() function, you use "\r\n" instead of just "\n" to separate the headers. This helps fix certain bugs on Windows systems that look for a carriage return instead of / in addition to a newline character.

So, you would change this:

$mailHeaders="From:$email1 \nReply-To:$email1 \nCc: $CCEMAILVARIABLE\nBcc: $BCCEMAILVARIABLE";

... to this:

$mailHeaders="From:$email1\r\nReply-To:$email1\r\nCc: $CCEMAILVARIABLE\r\nBcc: $BCCEMAILVARIABLE";
0
 
LVL 1

Author Comment

by:su-n
ID: 10792101
thanks a lot for your help!
0
 
LVL 8

Expert Comment

by:CoolATIGuy
ID: 10793776
n/p

Sorry about the CC: - was using my code and forgot your request. :-)  Did you get it working?



CoolATIGuy
0
 
LVL 1

Author Comment

by:su-n
ID: 10793884
yes, i added the 2nd mail line with my email addy :)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question