Jump to content

Newsletter - Forward To A Friend


joe124c41
 Share

Recommended Posts

I would like to setup something similar to this in the footer of my mass mailings for the convenience of the recipient, but in PHP:Forward to a friend example.I looked online and didn't see anything that specifically explained how to accomplish this.I am not too skilled at PHP so if anyone knows of a free script or can give me some guidance to accomplish this goal it would be greatly appreciated!!!Thanks in advance!!! :)

Link to comment
Share on other sites

  • 2 weeks later...
You'll need to include a link in the email to forward it to a friend. The link needs to identify the newsletter they want to forward, then they can fill in the details in the form.
I almost got it put together! I am stumped on these two things:It sends to all of the emails, but it is not correctly using the Blind carbon copy.How do I place the newsletter (mailer) either inside the email (preferably) or as an attachment?The forawardtoafriend.html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled Document</title></head><body><div><h1 align="left">Forward to a Friend</h1><div><script type="text/javascript">function validate_email(field,alerttxt){with (field){  apos=value.indexOf("@");  dotpos=value.lastIndexOf(".");  if (apos<1||dotpos-apos<2)    {alert(alerttxt);return false;}  else {return true;}  }}function validate_required(field,alerttxt){with (field){  if (value==null||value=="")    {alert(alerttxt);return false;}else {return true;}  }}function validate_email1(field,alerttxt){with (field){  apos=value.indexOf("@");  dotpos=value.lastIndexOf(".");  if (apos<1||dotpos-apos<2)    {alert(alerttxt);return false;}  else {return true;}  }}function validate_required1(field,alerttxt){with (field){  if (value==null||value=="")    {alert(alerttxt);return false;}else {return true;}  }}function validate_form(thisform){with (thisform){	if (validate_required(visitor,"Please type your name.")==false){visitor.focus();visitor.style.background = 'Yellow';return false;}if (validate_email(visitormail,"Please enter a valid e-mail address.")==false)    {visitormail.focus();visitormail.style.background = 'Yellow';return false;}		if (validate_required2(visitor1,"Please type your friend's name.")==false){visitor.focus();visitor2.style.background = 'Yellow';return false;}if (validate_email2(visitormail1,"Please enter a valid e-mail address for your friend.")==false)    {visitormail.focus();visitormail2.style.background = 'Yellow';return false;}	}}</script><form method="post" onsubmit="return validate_form(this);" action="forwardtoafriend.php"> <input type="hidden" name="attn" value="Email Subject" /> <table width="617">    <!--DWLayoutTable-->  <tr>    <td height="34" colspan="4" align="left" valign="top"><strong>Your Name:</strong><br /><br />      <input type="text" id="visitor" name="visitor" size="60" />      <br /></td>    <td colspan="3" align="left" valign="top"><strong>Your Email Address:</strong><br /><br /><input type="text" name="visitormail" size="60" id="email" /></td>    </tr>    <tr>    <td height="26" colspan="6" valign="middle"><br /><br /><hr align="center" />      Fill in the boxes below to send a personalized copy of this email to your friend(s).<hr align="center" /><br /><br /></td>    <td width="85"> </td>    </tr>  <tr>    <td width="1" height="42"> </td>    <td colspan="2" align="left" valign="top"><strong>1) Friend's Name:</strong><br /><br />      <input type="text" name="visitor1" size="60" /></td>    <td colspan="2" rowspan="7" valign="top"><!--DWLayoutEmptyCell--> </td>    <td colspan="2" valign="top"><strong>Email Address:</strong><br />      <br />      <input type="text" name="visitormail1" size="60" /></td>    </tr>  <tr>    <td height="42"></td>    <td colspan="2" valign="top"><strong>2) Friend's Name:</strong><br /><br />      <input type="text" name="visitor2" size="60" /></td>    <td colspan="2" valign="top"><strong> Email Address:</strong><br />      <br />      <input type="text" name="visitormail2" size="60" id="visitormail2" /></td>    </tr>      <tr>    <td height="42"></td>    <td colspan="2" valign="top"><strong>3) Friend's Name:</strong><br /><br />      <input type="text" name="visitormail3" size="60" /></td>    <td colspan="2" valign="top"><strong> Email Address:</strong><br />      <br />      <input type="text" name="visitormail3" size="60" /></td>    </tr>      <tr>    <td height="42"></td>    <td colspan="2" valign="top"><strong>4) Friend's Name:</strong><br /><br />      <input type="text" name="visitor4" size="60" /></td>    <td colspan="2" valign="top"><strong> Email Address:</strong><br />      <br />      <input type="text" name="visitormail4" size="60" /></td>    </tr>    <tr>    <td height="42"></td>    <td colspan="2" valign="top"><strong>5) Friend's Name:</strong><br /><br />      <input type="text" name="visitormail5" size="60" /></td>    <td colspan="2" rowspan="3" valign="top"><strong> Email Address:</strong><br />      <br />      <input type="text" name="visitormail5" size="60" /></td>    </tr>    <tr>    <td height="12"></td>    <td width="242"></td>    <td width="1"></td>    </tr>  <tr>    <td height="17" colspan="3" valign="top"><span class="righttxt"><strong>Add a Personal Message:</strong> (optional)</span></td>      </tr>      <tr>    <td height="135" colspan="7" valign="top"><textarea name="notes" rows="8" cols="60"></textarea></td>      </tr>    <tr>    <td height="44" colspan="2" valign="top"><input type="submit" value=" SEND " />      <input type="reset" value="RESET"></td>      <td> </td>    <td width="1"></td>    <td width="1"></td>    <td width="244"></td>    <td></td>    </tr>  </table>  </form></div></div></body></html>

The forawardtoafriend.php file:

<?php$visitor = $_POST['visitor'];$visitormail = $_POST['visitormail'];$visitor1 = $_POST['visitor1'];$visitormail1 = $_POST['visitormail1'];$visitor2 = $_POST['visitor2'];$visitormail2 = $_POST['visitormail2'];$visitor3 = $_POST['visitor3'];$visitormail3 = $_POST['visitormail3'];$visitor4 = $_POST['visitor4'];$visitormail4 = $_POST['visitormail4'];$visitor5 = $_POST['visitor5'];$visitormail5 = $_POST['visitormail5'];$notes = $_POST['notes'];$attn = $_POST['attn'];// VALIDATIONif (eregi('http:', $notes)) {die ("Do NOT try that! ! ");}if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))){echo "<h2>Use Back - Enter valid e-mail</h2>\n";$badinput = "<h2>Feedback was NOT submitted</h2>\n";echo $badinput;die ("Go back! ! ");}if(empty($visitor) || empty($visitormail) || empty($notes )) {echo "<h2>Use Back - fill in all fields</h2>\n";die ("Use back! ! ");}// DECLARATION$todayis = date("l, F j, Y, g:i a") ;$attn = $attn ;$subject = $attn ;$notes = stripcslashes($notes);$message = " $todayis [EST] \nI thought you might be interested in this newsletter. $notes \nSincerely, $visitor ($visitormail)\n";$from = "From: $visitormail\r\n";$mailto = "BCC:$visitormail1\r\n, BCC:$visitormail2\r\n, BCC:$visitormail3\r\n, BCC:$visitormail4\r\n, BCC:$visitormail5\r\n" ;mail($mailto, $subject, $message, $from);?><!--Feedback to user--><p align="center"><h3>Date: <?php echo $todayis ?></h3><br /><br /><h2>Thank You: <?php echo $visitor ?> ( <?php echo $visitormail ?> )</h2><br /><br /><h2>Message:<br /><?php $notesout = str_replace("\r", "<br/>", $notes);echo $notesout; ?></h2>

Link to comment
Share on other sites

If you want to attach the newsletter you'll need to use a more advanced mailing system, the Pear Mail package can handle attachments pretty easily. You can also just add the newsletter text to the body of the email.A BCC list does not go in the "to" field, BCC is a separate header. You still need a to address, so everyone on the BCC list is still going to see whatever email you add in the to field. You may want to send each person their own email. If you want to use BCC check here for an example:http://www.php.net/manual/en/function.mail.php

Link to comment
Share on other sites

The Pear Mail package will also handle text/html versions, the PHP manual also has an example of sending an HTML email.
Yeah, I am currently using Dada mail, which is Pearl. It's a great system that I found to be extremely customizable. The "forward to a friend" is a suggestion I i posted on the Dada support board. I am just trying to be productive and come up with the core of the solution.I get what you are saying about the TO: and I changed it, nowsending the emails individually instead of to multiple emails at once.
$mailto = "$visitormail1" ;$mailto2 = "$visitormail2" ;$mailto3 = "$visitormail3" ;$mailto4 = "$visitormail4" ;$mailto5 = "$visitormail5" ;mail($mailto, $subject, $message, $from);mail($mailto2, $subject, $message, $from);mail($mailto3, $subject, $message, $from);mail($mailto4, $subject, $message, $from);mail($mailto5, $subject, $message, $from);

Thanks for your help!

Edited by joe124c41
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...