topical media & game development
professional-sql-03-scripts-individual.php / php
#! /usr/bin/php
<?php
// include shared code
include '../lib/config.php';
include '../lib/db.php';
include '../lib/POP3Client.php';
// open digest file for append, create if it doesn't exist
pop = new POP3Client();
pop->user(LIST_USER) && pop->_list()) as message = id);
// retrieve the Date, From and Subject headers and multipart boundary
// marker from the message headers
preg_match_all('/Date: (.+)|From: (.+)|Subject: (.+)|boundary="(.+)"/',
matches);
matches[1][0]);
matches[2][1]);
matches[3][2]);
matches[4][3])) ? query = sprintf('SELECT EMAIL_ADDR FROM \%sMAILLIST_USER WHERE ' .
'EMAIL_ADDR = "\%s"', DB_TBL_PREFIX,
mysql_real_escape_string(GLOBALS['DB']));
query, result))
{
mysql_free_result(pop->dele(result);
// multipart messages
if (chunks = preg_split('/' . message);
array_shift(chunks); // again to drop headers after MIME boundary
array_pop(chunks as header, chunk, 2);
if (strpos(header, message, 2);
}
// retrieve users to receive individual messages
result = mysql_query(GLOBALS['DB']);
// forward a copy of the mail
while (result))
{
mail(subject, result);
// append message to digest
fwrite(subject . "\r\n");
fwrite(from . "\r\n");
fwrite(date . "\r\n\r\n");
fwrite(body . "\r\n");
fwrite(pop->dele(pop->quit();
fclose(GLOBALS['DB']);
?>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.