Forward to a friend PHP script

Posh

New Member
I would like to add a forward a friend link on my newsletters.

Do you have a PHP file or script which I can use.

Thanks
 

stanbusk

Administrator
Staff member
Try this one:
Code:
<? 
	//change this to your email. 
	$to      = "[email protected]"; 
	$from    = "[email protected]"; 
	$subject = "Forward test";
	$host    = "www.maxprog.com";
	$uri     = "/site/index_us.php";

	$fp = fsockopen ( $host, 80, $errno, $errstr, 30 );
	
	if (!$fp) {
		Exit( "Connection error #$errno:$errstr" );	
	} else {
		$out  = "GET " . $uri . " HTTP/1.1\r\n";
		$out .= "HOST: " . $host . "\r\n";
		$out .= "Content-type: text/html\r\n"; 
		$out .= "Connection: Close\r\n\r\n";
		fwrite( $fp, $out );
		while (!feof($fp)) {
			$in .= fgets ( $fp, 128 );
		}
		fclose ($fp);
	}
	
	$contents = Explode( "\r\n\r\n", $in );
	$message  = $contents[1];
	
	$message = str_replace( '</head>', '<base href="http://' . $host . '/"></head>', $message );

	$headers  = "From: $from\r\n"; 
	$headers .= "Content-type: text/html\r\n"; 

	//options to send to cc+bcc 
	//$headers .= "Cc: [email][email protected][/email]"; 
	//$headers .= "Bcc: [email][email protected][/email]"; 
 
	// now lets send the email. 
	mail( $to, $subject, $message, $headers ); 

	echo "Message has been sent....!"; 
?>
 

Posh

New Member
This is great. Thanks.

However I am not expert at PHP so can please you let me know I do I link to a button so that when the forwarder clicks on the forward button/text it forwards the e-mail with the attachments (if any) to the e-mail in the To: Box.

Do I have to copy and paste the code and create a PHP file.

Will the code automatically add the forwarders e-mail in the From box?

Do I need to change
$url = "/site/index_us.php";

or not.

If I do to what??

Is there anything else that I need to change in the script as well.

Sorry for so many questions.

Thanks
 

stanbusk

Administrator
Staff member
Do I have to copy and paste the code and create a PHP file.
Paste that text to a plain text file and save it as for example 'forward.php'. Then upload it to your server.
Do I need to change
$url = "/site/index_us.php";
Change all this:
$to = "[email protected]";
$from = "[email protected]";
$subject = "Forward test";
$host = "www.maxprog.com";
$uri = "/site/index_us.php";

This script is just an example, I did not write it actually, I just got it from the web after looking for it with Google. It lacks a way to provide the $to address, some kind of form. I wanted to integrate it with MLM but I had no time. You will find more scripts here or just design a form for the script I gave you with your HTML editor.
 
Top