Solved

How to add a bcc to this script?

Posted on 2004-04-08
8
347 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

730 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