Solved

How to add a bcc to this script?

Posted on 2004-04-08
8
342 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

910 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now