Send email to friend WITH article content

In this board you can talk about general questions about phpMyFAQ

Moderator: Thorsten

Post Reply
dudely
Posts: 12
Joined: Thu Jul 20, 2006 9:39 pm

Send email to friend WITH article content

Post by dudely »

Hello,
I'm trying to find a way to actually send the content of an article in an email instead of sending just the link. Is there a simple solution to this or is this a feature coming up in a later version? Thanks.

-Dan
matteo
Posts: 572
Joined: Sun Nov 20, 2005 6:53 pm
Location: Italy

Post by matteo »

Hi Dan,
this feature is not currently planned.
BTW, locate, backup and open the file [PATH_TO_PMFINSTALL]/mailsend2friend.php and find these lines below:

Code: Select all

...
     $name = $db->escape_string(strip_tags($_POST["name"]));
     $mailfrom = $db->escape_string(strip_tags($_POST["mailfrom"]));
     $link = $db->escape_string(strip_tags($_POST["link"]));
     $attached = $db->escape_string(strip_tags($_POST["zusatz"]));
     $mailto = $_POST['mailto'];
...
                mail($IDN->encode($mail), $PMF_LANG["msgS2FMailSubject"].$name, $PMF_CONF["send2friend_text"]."\n\n".$PMF_LANG["msgS2FText2"]."\n".$link."\n\n".$attached, "From: ".$IDN->encode($mailfrom));
...
and change them to read:

Code: Select all

...
    $name = $db->escape_string(strip_tags($_POST["name"]));
    $mailfrom = $db->escape_string(strip_tags($_POST["mailfrom"]));
    $link = $db->escape_string(strip_tags($_POST["link"]));
    $attached = $db->escape_string(strip_tags($_POST["zusatz"]));
    $body = $PMF_CONF["send2friend_text"]."\n\n".$PMF_LANG["msgS2FText2"]."\n".$link."\n\n";
    $isHTML = false;
    $idx   = preg_match('/action\=artikel&cat\=(\d+)&id\=(\d+)&artlang\=([a-z\-]+)/', $link, $matches);
    $id    = $matches[2];
    $lang  = $matches[3];
    $query = sprintf("SELECT thema, content, active FROM %sfaqdata WHERE id = %d AND lang = '%s'", SQLPREFIX, $id, $lang);
    $result = $db->query($query);
    if ($row = $db->fetch_object($result)) {
        if ('yes' == $row->active) {
            $isHTML  = true;
            $content = $row->content;
            $title   = $row->thema;
        }
    }
    $body .= "<br /><br />".$attached."<br /><br />".$content;
    $headers = "From: ".$IDN->encode($mailfrom)."\r\n";
    if ($isHTML) {
        $boundary = uniqid("MAILSENDPMF");
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: multipart/alternative; boundary = $boundary\r\n\r\n";
        $headers .= "This is a MIME encoded message.\r\n\r\n";
        // Plain text version of message
        $headers .= "--$boundary\r\nContent-Type: text/plain; charset=\"ISO-8859-1\"\r\nContent-Transfer-Encoding: base64\r\n\r\n";

        $headers .= chunk_split(base64_encode(strip_tags($body)))."\r\n";
        // HTML version of message
        $headers .= "--$boundary\r\nContent-Type: text/html; charset=\"ISO-8859-1\"\r\nContent-Transfer-Encoding: base64\r\n\r\n";
        $headers .= chunk_split(base64_encode("<html><head><title>".htmlentities($title)."</title></head><body>".$body."</body></html>"."\r\n"));
        $headers .= "--$boundary--\r\n";
    }
    $mailto = $_POST['mailto'];
...
                mail($IDN->encode($mail), $PMF_LANG["msgS2FMailSubject"].$name, $body, $headers);
...
That's all ;)

Ciao,
Matteo
phpMyFAQ QA / Developer
Amazon.co.uk Wishlist
dudely
Posts: 12
Joined: Thu Jul 20, 2006 9:39 pm

Post by dudely »

Thanks Matteo!
That works perfectly. I had come up with a solution on my own but I like yours better :wink: .

Dan
Post Reply