News:

CPG Release 1.6.29
During HTML5 upload, keep pseudo blank code 200 messages from triggering error condition
added Russian language
correct failure to use theme menu icons in album manager
minor vulnerabilities mitigation

Main Menu

[MOD] Newsletter: Send email to every user

Started by mushipkw, September 13, 2009, 01:10:07 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mushipkw

I have written a newsletter mod to send an email with subject & message body to every user of your website.
The mod formats the message with:
Dear "user_name",

"message"

You just have to write the subject & message, it will automatically add the user name to the message.

<?php

define
('IN_COPPERMINE'1);
require 
'include/init.inc.php';

if (!
GALLERY_ADMIN_MODEcpg_die(ERROR$lang_errors['access_denied'], __FILE____LINE__);

@
set_time_limit(1200);

$message '';
$subject '';

if ( isset(
$_POST['submit']) )
{
        
$subject stripslashes(trim($HTTP_POST_VARS['subject']));
        
$message stripslashes(trim($HTTP_POST_VARS['message']));
        
$test cpg_db_query("SELECT user_name, user_email FROM {$CONFIG['TABLE_USERS']} WHERE user_email <> ''");

$headers 'From: '.$CONFIG['gallery_admin_email']."\r\n" .
'Reply-To: '.$CONFIG['gallery_admin_email']."\r\n" .
'X-Mailer: PHP/' phpversion();

while ($row mysql_fetch_assoc($test)) {
$fullmessage '';
$fullmessage 'Dear ' $row['user_name'] . ',' chr(13) . chr(13) . $message;
@mail($row['user_email'], $subject$fullmessage$headers);

}
}

pageheader($massmailer_php['title']);
starttable('100%''Newsletter Mod By Mushi');

echo <<<EOT
        <form method="post" action="$PHP_SELF">
        <tr>
            <td width="40%" class="tableb">
                        Subject
        </td>
        <td width="60%" class="tableb" valign="top">
                <input type="text" style="width: 100%" name="subject" class="textinput">
                </td>
        </tr>
        <tr>
                <td class="tableb" valign="top">
                        Message
                </td>
                <td class="tableb" valign="top">
                        <textarea name="message" ROWS="5" COLS="40" SIZE="9"  WRAP="virtual" STYLE="WIDTH: 100%;" class="textinput">
$resmsg</textarea>
                </td>
        </tr>
        <tr>
                <td colspan="2" align="center" class="tablef">
                <input type="submit" name="submit" value="Submit" class="button">
                </td>
                </form>
        </tr>

EOT;

endtable();
pagefooter();
ob_end_flush();
?>


Its very basic because I am just a beginner in PHP