View previous topic :: View next topic |
Author |
Message |
hawkin
Joined: 18 May 2002 Posts: 11
|
Posted: Sat May 18, 2002 3:32 pm Post subject: Send post to Mailinglist |
|
|
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 |
|
 |
feelso
Joined: 30 May 2002 Posts: 52 Location: Paris, France
|
Posted: Fri May 31, 2002 2:17 am Post subject: |
|
|
Could you please tell me how to do this hack?
What do I have to change in b2edit.php?
thanks! |
|
Back to top |
|
 |
hawkin
Joined: 18 May 2002 Posts: 11
|
Posted: Sat Jun 01, 2002 10:58 am Post subject: |
|
|
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 |
|
 |
bigmoose
Joined: 25 Jun 2002 Posts: 5
|
Posted: Wed Jun 26, 2002 3:27 am Post subject: |
|
|
is there no way u could get it to set to multiple recipeints? |
|
Back to top |
|
 |
kaiden
Joined: 20 Mar 2002 Posts: 43
|
Posted: Wed Jun 26, 2002 11:52 pm Post subject: |
|
|
make a mailing list, if your host doesn't support thse, get a new host ;) |
|
Back to top |
|
 |
bigmoose
Joined: 25 Jun 2002 Posts: 5
|
Posted: Thu Jun 27, 2002 8:00 am Post subject: |
|
|
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 |
|
 |
nessahead
Joined: 12 Mar 2002 Posts: 312 Location: Los Angeles, CA
|
Posted: Thu Jun 27, 2002 10:02 pm Post subject: |
|
|
That's right  _________________ raar! |
|
Back to top |
|
 |
hawkin
Joined: 18 May 2002 Posts: 11
|
Posted: Fri Oct 04, 2002 1:47 am Post subject: cleaned up |
|
|
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 |
|
 |
bigmoose
Joined: 25 Jun 2002 Posts: 5
|
Posted: Fri Oct 04, 2002 8:12 am Post subject: |
|
|
thanks |
|
Back to top |
|
 |
hawkin
Joined: 18 May 2002 Posts: 11
|
Posted: Sat Oct 05, 2002 1:10 am Post subject: fix |
|
|
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 |
|
 |
michel v Site Admin
Joined: 25 Jan 2002 Posts: 799 Location: Corsica
|
Posted: Sun Oct 06, 2002 12:23 am Post subject: |
|
|
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 |
|
 |
Stacey
Joined: 11 Jan 2003 Posts: 2
|
Posted: Sat Jan 11, 2003 4:53 am Post subject: |
|
|
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 |
|
 |
hawkin
Joined: 18 May 2002 Posts: 11
|
Posted: Thu Feb 27, 2003 2:28 am Post subject: |
|
|
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 |
|
 |
Lusciousness
Joined: 04 Mar 2003 Posts: 12 Location: Pittsburgh, PA
|
Posted: Tue Mar 04, 2003 6:57 am Post subject: Ooh. |
|
|
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 |
|
 |
hawkin
Joined: 18 May 2002 Posts: 11
|
Posted: Wed Mar 05, 2003 1:04 am Post subject: |
|
|
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 |
|
 |
|