Solved

How to add a bcc to this script?

Posted on 2004-04-08
8
341 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
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.
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 …

747 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

13 Experts available now in Live!

Get 1:1 Help Now