Solved

How to add a bcc to this script?

Posted on 2004-04-08
8
345 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

831 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