Author Topic: forward this email to a friend  (Read 7184 times)

paulcj2

  • Posts: 23
    • View Profile
forward this email to a friend
« on: November 20, 2007, 04:20:21 pm »
I searched the forum for "forward," but found nothing. My experience is that when I receive in Outlook one of my own email newsletters sent out by my ListMail installation, and then try to forward it, Outlook does a hatchet job on my markup, such that the newsletter is not what I want it to be. I can imagine my newsletter recipients trying to do the same thing.

I notice that Maildog newsletters also get hatcheted when I receive them in Outlook and try to forward them to myself. Their work-around is to provide a link from an email "Send to a friend." Apparently this allows the viewer to send a copy to a friend from the MailDog server, so Outlook or some other email recipient program doesn't do a hatchet job on it. Can something like this be done with ListMail?

paulcj2

  • Posts: 23
    • View Profile
Any thoughts?
« Reply #1 on: December 09, 2007, 07:03:14 am »
It has been a while since I posted this and I have had no response. Let me state the question again.

How do I set up a link in my newsletter so that a person can send a fresh copy to a friend directly from the server instead of forwarding the newletter.

Any thoughts?

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
forward this email to a friend
« Reply #2 on: December 10, 2007, 11:40:34 pm »
Hi, Basically you'd need a custom script that could load the "current" user via the users' Unique ID, outputtable via message code.  You would then enter a link such as follows in your messages:

http://example.com/mail/tell-a-friend.php?u=!uid

The tell-a-friend.php script would contain some code like this:

Code: [Select]
<?php
// Connect to ListMail DB / Initialize
include('./config.php');
include(
'./admin.php');

// Submit Processing
if($submitted){
 if(!
$friendName){
  echo 
"Please enter your friend's name.<br>";
 } elseif(!
$friendEmail){
  echo 
"Please enter your friend's email address.<br>";
 } elseif(!
valid_email($friendEmail)){
  echo 
"Please enter a valid friend email address.<br>";
 } else {
  
// all ok, get current user info from ListMail  list($curFirst,$curLast,$curEmail)=@mysql_fetch_row(mysql_query("select fname,lname,email from $utable where uid = '".addslashes($u)."';"));
  
if(!$curFirst) exit('User not found');
  
$sendName "My Site";
  
$sendEmail "me@example.com";
  
$subject "Hey, $friendName - $curFirst wants you to check this out";
  
$message "";
  
mail($friendEmail,$subject,$message,"Return-path: <$sendEmail>\nFrom: \"$sendName\" <$sendEmail>");
 } 
}

// Main page
echo "<form method=post action=./tell-a-friend.php>
<input type=hidden name=submitted value=1>
Friend's name: <input type=text name=friendName><br>
Friend's Email: <input type=text name=friendEmail><br>
</form>\n"
;

?>


Note: untested ;)
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

paulcj2

  • Posts: 23
    • View Profile
forward this email to a friend
« Reply #3 on: December 11, 2007, 03:56:43 pm »
Thanks. I'll give it a whirl.

paulcj2

  • Posts: 23
    • View Profile
Getting to this at last
« Reply #4 on: May 19, 2008, 06:04:42 am »
Dean,

I'm getting to this at last. I have:
1) installed the .php file configured for my site
www.clickbasics.com/mail/tell-a-friend.php

2) linked to it from an e-mail newslwtter
<p><a href="http://www.clickbasics.com/mail/tell-a-friend.php?u=!uid">Share this newsletter with a friend.</a></p>

However, when I test it with a real user (me)
http://www.clickbasics.com/mail/tell-a-friend.php?u=33912bd

after adding a test name and e-mail addres (again, me" Paul Carter, paulc@clickbasics.com) the query does not find me as the user. On hitting the "Submit" button, I get the message: "User not found."

I checked the table "lm_user" and the user record is fine. I suspect the problem is in the following query:

list($curFirst,$curLast,$curEmail)=@mysql_fetch_row(mysql_query("select fname,lname,email from $utable where uid = '".addslashes($u)."';"));
  if(!$curFirst) exit('User not found');

Please advise.

My full code follows.

Paul C.
----------
<?php
///mail/tell-a-friend.php
//created 12/12/2007
//modified 5/19/2008
// Connect to ListMail DB / Initialize
include('./config.php');
include('./admin.php');

// Submit Processing

$friendName = $_POST['friendName'];
$friendEmail = $_POST['friendEmail'];
 
if (isset($_POST['Submit']))
{
 if(!$friendName){
  echo "Please enter your friend’s name.<br />";
 } elseif(!$friendEmail){
  echo "Please enter your friend’s email address.<br />";
 //} elseif(!valid_email($friendEmail)){
  } elseif(!$friendEmail){
  echo "Please enter a valid friend email address.<br />";
 } else {
  //all ok, get current user info from ListMail
list($curFirst,$curLast,$curEmail)=@mysql_fetch_row(mysql_query("select fname,lname,email from $utable where uid = '".addslashes($u)."';"));
  if(!$curFirst) exit('User not found');
  $sendName = "ClickBasics";
  $sendEmail = "service@clickbasics.com";
  $subject = "Greetings, $friendName - $curFirst wants you to check this out";
  $message = "A friend sent you this.";
  mail($friendEmail,$subject,$message,"Return-path: <$sendEmail>\n
  From: \'$sendName\' <$sendEmail>");
 }
}
// Main page
?>


<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1" />
<title>Tell a Friend</title>
</head>

<html>
<head>
   <title>Tell a Friend</title>
</head>

<body><form method=post action=./tell-a-friend.php>
   <input type="hidden" name="submitted" value="1">
Your friend’s name: <input type="text" name="friendName"><br />
Your friend’s e-mail: <input type="text" name="friendEmail"><br />

    <input type="submit" name="Submit" id="Submit" value="Submit" class="btn" />
</form>
</body>
</html>

paulcj2

  • Posts: 23
    • View Profile
Never mind
« Reply #5 on: May 19, 2008, 09:12:45 am »
Dan,

Never mind. I got around it with alternate code as follows:

Paul C.
--------------

$result = mysql_query("SELECT fname, lname, email FROM $utable where uid = '".addslashes($u)."';");
 if (!$result) {
    exit('<p>Error fetching user details: ' .
        mysql_error() . '</p>');
      }
      
  $usr = mysql_fetch_array($result);
  $usrFirst = $usr['fname'];
  $usrLast = $usr['lname'];
  $usrEmail = $usr['email'];

debbuxton

  • Posts: 23
    • View Profile
follow up on this...change in from email and post?
« Reply #6 on: June 15, 2008, 08:31:01 pm »
Hey there,

I am testing this out. I am wondering why the from email is not coming through as what I have designated it as.

Also is it possible to have the message send in html? I would like the message sent to the friend to be html.

Thanks for any help.

d

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
forward this email to a friend
« Reply #7 on: June 18, 2008, 08:54:05 am »
If the following doesn't properly set the "From" email:
Code: [Select]
mail($friendEmail,$subject,$message,"Return-path: <$sendEmail>\n
From: \'$sendName\' <$sendEmail>");

You can try this:
Code: [Select]
mail($friendEmail,$subject,$message,"Return-path: <$sendEmail>\n
From: \'$sendName\' <$sendEmail>","-f$sendEmail");

An HTML message is more complicated.  Basically we need to use the included "mime class" that comes with ListMail to build the message, like this:
Code: [Select]
$mail = new html_mime_mail();
$mail->add_text($textmsg);
$mail->add_html($htmlmsg);
$build_params = array();
$build_params['html_charset'] = 'iso-8859-1';
$build_params['text_charset'] = 'iso-8859-1';
 $mail->build_message($build_params);

 // create final message
 $body = $mail->output;
 $headers = $mail->headers;
 $header = '';
 $crlf = "\n";
 $header .="From: \"$sendName\" <$sendEmail>$crlf";
 $header .= "Return-Path: $sendEmail$crlf";
 $header .= "MIME-Version: 1.0$crlf";
 while(list($key2,$data) = each($headers)) $header .= $data.$crlf;
 $header .="X-Mailer: ListMailPRO$crlf";
 if($htmlmsg) $header .= $crlf."This is a multipart message in MIME format.";

 // send msg
 mail($friendEmail,$subject,$body,$header,"-f$sendEmail")


Regards
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting