Welcome to Geeklog, Anonymous Friday, April 19 2024 @ 04:38 pm EDT

Geeklog Forums

Modified profiles.php - send a story now inserts "!"


julianna

Anonymous
I modified the code in profiles.php to customize the email which was sent when the "Mail Story" feature is used. Basically, I wanted to strip the email of everything except the intro, body, the separating line, and the link.

This is the code after the change:

Text Formatted Code

function mailstory ($sid, $to, $toemail, $from, $fromemail, $shortmsg)
{
        global $_CONF, $_TABLES, $_USER, $LANG01, $LANG08;

    $retval = COM_refresh (COM_buildUrl ($_CONF['site_url']
                                         . '/article.php?story=' . $sid));

    // check for correct $_CONF permission
    if (empty ($_USER['username']) &&
        (($_CONF['loginrequired'] == 1) || ($_CONF['emailstoryloginrequired'] == 1))) {
        return $retval;
    }

    // check if emailing of stories is disabled
    if ($_CONF['hideemailicon'] == 1) {
        return $retval;
    }

    // check mail speedlimit
    COM_clearSpeedlimit ($_CONF['speedlimit'], 'mail');
    if (COM_checkSpeedlimit ('mail') > 0) {
        return $retval;
    }

        $sql = "SELECT uid,title,introtext,bodytext,UNIX_TIMESTAMP(date) AS day FROM {$_TABLES['stories']} WHERE sid = '$sid'";
        $result = DB_query ($sql);
        $A = DB_fetchArray ($result);
    $shortmsg = COM_stripslashes ($shortmsg);
        $mailtext = sprintf ($LANG08[23], $from, $fromemail) . LB;
        if (strlen ($shortmsg) > 0) {
                $mailtext .= LB . sprintf ($LANG08[28], $from) . $shortmsg . LB;
        }
    $mailtext .= LB
                . COM_undoSpecialChars(stripslashes(strip_tags($A['introtext']))).LB.LB
                . COM_undoSpecialChars(stripslashes(strip_tags($A['bodytext']))).LB.LB
                . '------------------------------------------------------------'.LB
                . $LANG08[24] . LB
        . COM_buildUrl ($_CONF['site_url'] . '/article.php?story=' . $sid
                        . '#comments');

    $mailto = COM_formatEmailAddress ($to, $toemail);
    $mailfrom = COM_formatEmailAddress ($from, $fromemail);
        $subject = COM_undoSpecialChars(strip_tags(stripslashes('From Julie's Blog: '.$A['title'])));

    COM_mail ($toemail, $subject, $mailtext, $mailfrom);
    COM_updateSpeedlimit ('mail');

        // Increment numemails counter for story
    DB_query ("UPDATE {$_TABLES['stories']} SET numemails = numemails + 1 WHERE sid = '$sid'");

        return $retval;
}

 


The problem is when I use the "Mail Story" feature now, the line breaks are in strange places and I sometimes get exclamation marks in strange places:



I figure I should be going !
out there if I'm the one who moved Wink I'll be avoiding visitin!
g on lon
g-weekends though


and


"The Mythical Man-Month", which is about scheduling comput!
er-design projects).


Is there something I changed which caused this?
 Quote

Status: offline

matthewcox

Forum User
Junior
Registered: 12/11/03
Posts: 31
Location:Asheville, North Carolina
After comparing the code, I was stumped. Then a short trip over to google revealed the quote below(top result).
Found this quote by googling - php mail exclamation "line breaks"


26-May-2005 04:18

If you are seeing unwanted line breaks preceded by exclamation marks
("!") in the emails you send with mail(), you may be having the same
problem I had: exceeding the maximum line length (998 chars) specified
in RFC 2822 (http://www.faqs.org/rfcs/rfc2822.html).

You can get around this restriction by using base64 encoding: add a
"Content-Transfer-Encoding: base64" header and encode the contents with

$base64contents = rtrim(chunk_split(


base64_encode($contents)));


This is quoted from php.net from this page

-Matthew Cox
     5  Quote

julianna

Anonymous
Thanks!
 Quote

All times are EDT. The time is now 04:38 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content