Topic: emailing all forum users

is it possible to email all the users of my forum?
greetz Bas

Re: emailing all forum users

There is no such feature in PunBB, but writing a small script that does the job is easy.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: emailing all forum users

But i don't know how to write a script like that.........

Re: emailing all forum users

Here you go. Just put this file in the forum root directory and run it. It will generate a file called mlist.txt containing a comma-separated list of all e-mail addresses in your forum.

<?php
/***********************************************************************

  Copyright (C) 2002, 2003  Rickard Andersson (punbb@telia.com)

  This file is part of PunBB.

  PunBB is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published
  by the Free Software Foundation; either version 2 of the License,
  or (at your option) any later version.

  PunBB is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  MA  02111-1307  USA

************************************************************************/


require 'config.php';

require 'include/common.php';


if ($cur_user['status'] < 2)
    message($lang_common['No permission']);


$fh = fopen('mlist.txt', 'w');
if (!$fh)
    exit('Unable to open mlist.txt for writing.');

$result = $db->query('SELECT email FROM '.$db->prefix.'users WHERE id>1 ORDER BY id') or error('Unable to fetch user e-mail addresses', __FILE__, __LINE__, $db->error());

$num_emails = $db->num_rows($result);

for ($i = 0; $i < $num_emails; $i++)
{
    $cur_email = $db->result($result, $i);
    fwrite($fh, $cur_email);

    if (($i+1) < $num_emails)
        fwrite($fh, ', ');
}

fclose($fh);

exit('mlist.txt generated.');
"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: emailing all forum users

thank u man!!!!!!!!!!!!!!!!! big_smile big_smile

6

Re: emailing all forum users

Nice one Kennel!

---------> PLEASE REMEMBER I GOT THE FIRST EVER POST OF PUNBB 1.1! <---------
---------> PLEASE REMEMBER I GOT THE FIRST EVER POST OF PUNBB 1.1! <---------