boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Send post to Mailinglist
Goto page 1, 2  Next
 
Post new topic   Reply to topic    boardom Forum Index -> Feature requests
View previous topic :: View next topic  
Author Message
hawkin



Joined: 18 May 2002
Posts: 11

PostPosted: Sat May 18, 2002 3:32 pm    Post subject: Send post to Mailinglist Reply with quote

Would be nice with a feature, so posts in specific categories will be sent to a specified mailaddress (mailinglist), or even better: users registered, could subscribe to different categories, and they would get an e-mail when new post are made.

For now, I've just hacked in a mail() call in b2edit.php file, for this to work.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
feelso



Joined: 30 May 2002
Posts: 52
Location: Paris, France

PostPosted: Fri May 31, 2002 2:17 am    Post subject: Reply with quote

Could you please tell me how to do this hack?

What do I have to change in b2edit.php?

thanks!
Back to top
View user's profile Send private message
hawkin



Joined: 18 May 2002
Posts: 11

PostPosted: Sat Jun 01, 2002 10:58 am    Post subject: Reply with quote

It's not a pretty hack, but it works for my needs right now.
It sends out e-mail to a predefined address in config file ($maillist), for a special category (cat=3). All other cat's does not send out e-mail.

Here's the edited code in b2edit.php (you also need to add the $maillist="[email protected]" in the config fil, like the admin e-mail):
Code:

switch($action) {

case "post":

        $standalone = 1;
        include_once("./b2header.php");

        $emailcontent = $content;

        $content = format_to_post($content);

        $content = balanceTags($content);

        $post_title = addslashes($post_title);

        if ($user_level == 0)
        die ("Cheatin' uh ?");

        $now = date("Y-m-d H:i:s",(time() + ($time_difference * 3600)));

        $query = "INSERT INTO $tableposts (ID, post_author, post_date, post_content, post_title, post_category) VALUES ('0','$user_ID','$now',
'$content','$post_title','$post_category')";
        $result = mysql_query($query);

        if (!$result)
        die ("Error in posting... contact the <a href=\"mailto:$admin_email\">webmaster</a>");

        rss_update($blog_ID);
        pingWeblogs($blog_ID);
        pingCafelog($cafelogID, $post_title, $post_ID);

        if($post_category == 3) {
        $mailheader = "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type
        $emailcontent = $emailcontent . "\n"
        . "---------------------------------------------------------------"
        . "\n" . "Denne artikkelen kom fra <a href=\"http://haagen.waade.net\">[haagen.waade.net]</a>";
        $emailcontent = stripslashes(nl2br($emailcontent));
        $post_title = "[haagen.waade.net] " . $post_title;
        @mail($maillist, $post_title, $emailcontent, "From: \"Haagen Waade\" <[email protected]>\nReturn-Path: <[email protected]>\r\n"."X-M
ailer: b2 v0.6 - PHP/" . phpversion()."\r\n".$mailheader);
        }
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
bigmoose



Joined: 25 Jun 2002
Posts: 5

PostPosted: Wed Jun 26, 2002 3:27 am    Post subject: Reply with quote

is there no way u could get it to set to multiple recipeints?
Back to top
View user's profile Send private message
kaiden



Joined: 20 Mar 2002
Posts: 43

PostPosted: Wed Jun 26, 2002 11:52 pm    Post subject: Reply with quote

make a mailing list, if your host doesn't support thse, get a new host ;)
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
bigmoose



Joined: 25 Jun 2002
Posts: 5

PostPosted: Thu Jun 27, 2002 8:00 am    Post subject: Reply with quote

so i would make a mailing list using host features and then send the email to that one recipient that would in turn send it to all addresses?
Back to top
View user's profile Send private message
nessahead



Joined: 12 Mar 2002
Posts: 312
Location: Los Angeles, CA

PostPosted: Thu Jun 27, 2002 10:02 pm    Post subject: Reply with quote

That's right Smile
_________________
raar!
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
hawkin



Joined: 18 May 2002
Posts: 11

PostPosted: Fri Oct 04, 2002 1:47 am    Post subject: cleaned up Reply with quote

Since upgrading with the new b2 versions, my mailinglist hack went out the door.
I've now cleaned up some of the code, and made it a bit more configurative.

Theese are settings which have to be put into b2config.php or b2maillist.php:
Code:

$maillist = "maillist@domain"; // the mailinglist address
$mailsubject = "[$blogname] "; // first part of the e-mail subject (last part = post title)
$mailheader = ""; // text to put in the e-mail before the content
$mailfooter =    "\n"
           . "---------------------------------------------------------------"
           . "\n" . "This article came from <a href=\"$siteurl\">[$blogname]</a>";
// text to put in the e-mail after the content
$maillist_category = 3; // only posts with this category will send out mail to the mailinglist (need to make this with an array to enable >1 cat)


Then, in b2edit.php, there need to be inserted one line.
From this:
Code:

case 'post':

        $standalone = 1;
        require_once('./b2header.php');

        $post_autobr = intval($HTTP_POST_VARS["post_autobr"]);
        $post_pingback = intval($HTTP_POST_VARS["post_pingback"]);
        $content = balanceTags($HTTP_POST_VARS["content"]);
        $content = format_to_post($content);
        $post_title = addslashes($HTTP_POST_VARS["post_title"]);
        $post_category = intval($HTTP_POST_VARS["post_category"]);


to this:
Code:

case 'post':

        $standalone = 1;
        require_once('./b2header.php');

        $post_autobr = intval($HTTP_POST_VARS["post_autobr"]);
        $post_pingback = intval($HTTP_POST_VARS["post_pingback"]);
        $content = balanceTags($HTTP_POST_VARS["content"]);
        $post_title = addslashes($HTTP_POST_VARS["post_title"]);
        $post_category = intval($HTTP_POST_VARS["post_category"]);
        include("b2maillist.php");
        send_to_mailinglist($content, $post_category, $post_title)
        $content = format_to_post($content);


then make a new fil, called b2maillist.php with all the other files, and paste this code in:
Code:

function send_to_mailinglist($content, $post_category, $post_title){
   global $mailheader, $mailfooter, $mailsubject, $maillist, $maillist_category
   global $admin_email, $blogname;

   if($post_category == $maillist_category) {
        $mimeheader = "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type
        $body = $mailheader . $content . $mailfooter;
        $body = stripslashes(nl2br($body));
        $subject = $mailsubject . $post_title;
        @mail($maillist, $subject, $body, "From: \"$blogname\" <$admin_email>\nReturn-Path: <$admin_email>\r\n"."X-M
ailer: b2 - PHP/" . phpversion()."\r\n".$mimeheader);
   }
}
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
bigmoose



Joined: 25 Jun 2002
Posts: 5

PostPosted: Fri Oct 04, 2002 8:12 am    Post subject: Reply with quote

thanks
Back to top
View user's profile Send private message
hawkin



Joined: 18 May 2002
Posts: 11

PostPosted: Sat Oct 05, 2002 1:10 am    Post subject: fix Reply with quote

Just discovered some bugs in the hack I posted.
I've fixed thoose, and for convenience, I'm posting a link to the hack instead (the admin here should really consider to install the attachment addon for phpbb):
http://hawkin.waade.net/b2-tools/b2_maillist.zip

It should include everything you need.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
michel v
Site Admin


Joined: 25 Jan 2002
Posts: 799
Location: Corsica

PostPosted: Sun Oct 06, 2002 12:23 am    Post subject: Reply with quote

The admin here pays for bandwidth, so the admin here doesn't see adding an attachment mod as a Good Thing (tm)
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
Stacey



Joined: 11 Jan 2003
Posts: 2

PostPosted: Sat Jan 11, 2003 4:53 am    Post subject: Reply with quote

How would I alter this script to have the author's ID included in the email so members of the list would know who wrote the post? I've got a group log & I'd like the members of the log to get posts via email
Back to top
View user's profile Send private message Visit poster's website AIM Address
hawkin



Joined: 18 May 2002
Posts: 11

PostPosted: Thu Feb 27, 2003 2:28 am    Post subject: Reply with quote

Stacey: It cerently is posible, but havent been able too look at that modification. Shouldnt be much of a hassle though.

Ill post an update soon.

admin: This thread should be moved to Hacks forum.. since its not a request, but a mod :)
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Lusciousness



Joined: 04 Mar 2003
Posts: 12
Location: Pittsburgh, PA

PostPosted: Tue Mar 04, 2003 6:57 am    Post subject: Ooh. Reply with quote

Thanks! I really like this script. I've noticed that there's a lag between when I make a post and when I'm notified, but maybe that's just the mailing list script I'm using.
Hmmm. Question... what if I don't want people to see the content of my post in their email? What variable would I delete? $content? I tried that before, but got some weird results... eh... let me try again.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
hawkin



Joined: 18 May 2002
Posts: 11

PostPosted: Wed Mar 05, 2003 1:04 am    Post subject: Reply with quote

the variable which contains the mailbosy is $body.
if you remove that from my hack you will get an empty mail:

// $body = $mailheader . $content . $mailfooter;
// $body = stripslashes(nl2br($body));

I would suggest to put something in the body, but maybe just a link to where you would be able to find the post on the web. ie:
$body = "Read it at: <a href=\"$siteurl\">[$blogname]</a>";

What would be the best is a link directly to that post that was made, but that requires abit of modification to my hack (needs a input of the post id in addition).
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> Feature requests All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group