Fork me on GitHub

receiving mail when a new comment is posted  Bottom

  • I'm hacking the NS-Comments "index.php" file in order to make it send me an email when a new comment is posted.

    I add (after line 1169 - after the data is inserted into the pntables) the "core" postnuke sendmail string like:

    Code

    pnMail('myemail@mysite.es', "New Comment", "please read", "imagicweb_post" );
    and it works.

    But I would like to include in the body of the message the subject of the commented story, as it has previously INSERTED in the database...

    Can someone give me a hand on this?

    Thanks!
  • I also wanted something like you did.

    In the index.php I added after row 1143:

    Code

    // mrpq
          $maxTextLenght=15;
          $aspace=" ";
          if(strlen($comment) > $maxTextLenght ) {
         $comment = substr(trim($comment),0,$maxTextLenght);
         $comment = substr($comment,0,strlen($comment)-strpos(strrev($comment),$aspace));
         $comment = $comment.'...';
      }

            global $HTTP_SERVER_VARS;
            $site_url = $HTTP_SERVER_VARS['HTTP_HOST'];
            $from = pnConfigGetVar('adminmail');
            $email2 = "<mail1@somewhere.com>,<mail2@somewhere.com>";
            $subject2 = ""._YOURHOMEPAGE." "._COMMENT."";
            $message2 = "<table border=0><tr><td><b>"._SUBJECT.": </b></td><td>$subject</td></tr><tr><td><b>"._CONTENT.": </b></td><td>$comment</td></tr></table><br>"._THEURL." <a href=http://$site_url/modules.php?op=modload&name=News&file=article&sid=$sid>http://$site_url/modules.php?op=modload&name=News&file=article&sid=$sid</a>";
            pnMail($email2, $subject2, $message2, "From: $from\nX-Mailer: PHP/\nMIME-Version: 1.0\nContent-type: text/html; charset=iso-8859-1\n", 0);
           
    //mrpq


    Try it on your own risk.
    If someone knows a better code, please let me know.
  • hey, It seems GOOD!
    Anyway, the best hack will be the one who send the mail to the admin but ALSO the the one who has published the news story...
    Regards
  • You know that the mail comes from your PN Site!
    But if the user is logged in, it's possible toe get the users vars with the pnUserGetVar() function.

    Replace:

    Code

    $from = pnConfigGetVar('adminmail');

    With:

    Code

    $from = pnUserGetVar('email');


    I don't suppose you want to know who published the news, but published the comment.
    To see the username who send the comment, place a another tabelrow between the
    tag.

    Code

    <tr><td><b>"._POSTEDBY.":</b></td><td>$uname</td><tr>


    Regards,

    MRPQ
  • Great, thank you very much!

    I think this hack must be in PN 7 final or in 8 as a default choice... But I guess this choice should be available in the Administration -> Settings section... and this is a more deep hack...

    Also I have asked at noc.postnuke.com for receiving mail when a Private Message is posted...

    Have a nice day!
  • 0 users

This list is based on users active over the last 60 minutes.