secret forward

bunglebrown

New Member
Messages
157
Reaction score
0
Points
0
I have a section where users can send a link to a friend but I don't know how to forward that info onto myself so that they cannot see it (using BCC I believe). This is part of what I have (below) but of course it doesn't do what I want. Can someone feed me the missing link or advise me on what I'm doing wrong.

PHP:
 $to = "$toEmail";
 $bcc = myemail@hostage.com
    
mail($to, $subject, $message, $headers, $bcc);
 

bunglebrown

New Member
Messages
157
Reaction score
0
Points
0
Re: separate greetings

Well I've resolved that issue - I am now onto something else. . .

I have a name field whereby users enter the name of the friend they wish to refer and they are greeted with - " Hi $toName, blah blah...". However if the user enters multiple email addresses (separating them with commas) to refer more than one person they are all greeted with the same name. The user cannot simply separate the name with a comma. Does anyone have any suggestions as to how they can each be greeted with their individual names? in thanks
 

VPmase

New Member
Messages
914
Reaction score
1
Points
0
Re: separate greetings

Use arrays.

If you list what the vars are I could show you what I mean.
 

bunglebrown

New Member
Messages
157
Reaction score
0
Points
0
I think you understand what I mean with the names so -here's the code:

PHP:
<?php
 
// Create local PHP variables from the info the user gave in the Flash form -disabled message field
$toName   = $_POST['toName'];
$toEmail   = $_POST['toEmail'];
$fromEmail = $_POST['fromEmail'];
 
// Strip slashes on the Local variables -disabled message field
$toName   = stripslashes($toName);
$toEmail      = stripslashes($toEmail);
$fromEmail   = stripslashes($fromEmail);
 
    $to = $toEmail;
    $from = $fromEmail;
    $subject = "title";
    //Begin HTML Email Message
    $message = <<<EOF
<html>
  <body bgcolor="#FFFFFF">
<b>Hi $toName,<br />
<b>            check this out !! <br />
<b>      <a href="http://website.com</a><br />
<b>            <br />
  </body>
</html>
EOF;
   //end of message
    $headers  = "From: $from\r\n";
    $headers .= "Content-type: text/html\r\n";
    $headers .= "Bcc: myaddress@host.com";
    $to = "$to";
 
    mail($to, $subject, $message, $headers);
   
exit();
?>
 

VPmase

New Member
Messages
914
Reaction score
1
Points
0
Ok well I can modify your script to have it put only 1 name per email message but that would require having separate mail() statements for each person.
 

bunglebrown

New Member
Messages
157
Reaction score
0
Points
0
Can we do that because I've messed about with that a little and it didn't seem to like it, e.g. even putting two identical doesn't work:

PHP:
    mail($to, $subject, $message, $headers);
    mail($to, $subject, $message, $headers);

how do you suggest we do it?
 

Nathan H

New Member
Messages
562
Reaction score
0
Points
0
Have you tried adding wait/sleep commands in between the mail commands, anti-spam scripts would block a script that tries to mail near perfect copies to serveral emails at once.
 

Nathan H

New Member
Messages
562
Reaction score
0
Points
0
in php use
sleep($int);
where $int is the time you want to wait in seconds, try using 1 here
 

bunglebrown

New Member
Messages
157
Reaction score
0
Points
0
definitely useful and it works but how could I alter the message for each so that only each person's address is seen in the address bar instead of multiple addresses and so that each friend is greeted with only their name? I'm just wondering because the user can only divide the names and email addresses with commas in the input boxes.
 

VPmase

New Member
Messages
914
Reaction score
1
Points
0
Something like this should work.

PHP:
<?php
 
// Create local PHP variables from the info the user gave in the Flash form -disabled message field
$toName   = $_POST['toName'];
$toEmail   = $_POST['toEmail'];
$fromEmail = $_POST['fromEmail'];
 
// Strip slashes on the Local variables -disabled message field
$toName   = stripslashes($toName);
$toEmail      = stripslashes($toEmail);
$fromEmail   = stripslashes($fromEmail);
 
    $from = $fromEmail;
    $subject = "title";
	$toe = split($toEmail, ",");
	$ton = split($toName, ",");
	$n = sizeof($toe);
    //Begin HTML Email Message
	for($i=0;$i<$n;$i++){
		$to = $toe[$i];
		$name = $ton[$i];
		$message = <<<EOF
<html>
  <body bgcolor="#FFFFFF">
<b>Hi $name,<br />
<b>            check this out !! <br />
<b>      <a href="http://website.com">LINK</a><br />
<b>            <br />
  </body>
</html>
EOF;
   //end of message
    $headers  = "From: $from\r\n";
    $headers .= "Content-type: text/html\r\n";
    $headers .= "Bcc: myaddress@host.com";
 
    mail($to, $subject, $message, $headers);
   }
exit();
?>
 

bunglebrown

New Member
Messages
157
Reaction score
0
Points
0
strictly speaking that didn't work but sure was a nice effort. Not sure why but it didn't send to the variables - only forwarded to me. Perhaps it was because it didn't have the $to = $tomail at the bottom like the others - I'm not sure to be honest.

If this is possible though I know we'll do it - it seemed to be the right lines.
 

VPmase

New Member
Messages
914
Reaction score
1
Points
0
Maybe if you add

PHP:
$headers .= 'To: ' . $toEmail . "\r\n";
 

bunglebrown

New Member
Messages
157
Reaction score
0
Points
0
nor does this work - I've tried various combinations as well but this one doesn't work. Have you already done this? Does it definitely work? 'cos if so then it must be something this end/

I appreciate the plugs here

----------------------------------
I've just seen that actually with this recent addition it does send to the second email address but not the first and the $name doesn't work it is just an empty space. Anymore suggestions? - I think we are close.
 
Last edited:

bunglebrown

New Member
Messages
157
Reaction score
0
Points
0
To reiterate...

- If anyone knows how to specify individual $name variables so that each email recipient receives a greeting with only their individual name I (and countless others I'm sure) would like to hear from you.

with patient thanks/
 
Top