View Full Version : Need help with email.php
Parker Clack
04-23-2002, 03:52 PM
In admin/email.php you can generate a mailing list but I would also like for a text file to be written at the same time it is creating the list.
The fetch array is:
$users=$DB_site->query("SELECT email FROM user WHERE $condition AND adminemail=1");
while ($user=$DB_site->fetch_array($users)) {
echo $user[email].$septext;
flush();
}
}
What could I put in here so that it captures all the $user[email]
and writes it to a text file with today's date?
Thanks,
Parker
Sparkz
04-23-2002, 04:19 PM
$users=$DB_site->query("SELECT email FROM user WHERE $condition AND adminemail=1");
unset ($mailinglist);
while ($user=$DB_site->fetch_array($users)) {
echo $user[email].$septext;
$mailinglist .= $user[email].$septext;
flush();
}
$mailpath = "/path/to/dir/writable/by/webserver/";
$mailpath .= date('Y-m-d', time()) . ".txt";
writetofile ($mailpath, $mailinglist);
This should work - in theory.
writetofile() is a function in adminfunctions.php, which I have never used before. I just noticed while browsing the file.
Another possible way could be:
$users=$DB_site->query("SELECT email FROM user WHERE $condition AND adminemail=1");
$mailpath = "/path/to/dir/writable/by/webserver/";
$mailpath .= date('Y-m-d', time()) . ".txt";
$fp = fopen($mailpath, 'w');
unset ($mailinglist);
while ($user=$DB_site->fetch_array($users)) {
echo $user[email].$septext;
$buf = $user[email].$septext;
fputs ($fp, $buf);
flush();
}
fclose ($mailpath);
Both of these are untested, they are just suggestions as usual.
Parker Clack
04-23-2002, 05:35 PM
Sparkz:
The second example works great. The only problem is that the line breaks are put into the .txt file as <br>. What would you recommend using to put a line break between each email address in the resultant .txt file?
Parker
Sparkz
04-23-2002, 06:04 PM
$users=$DB_site->query("SELECT email FROM user WHERE $condition AND adminemail=1");
$mailpath = "/path/to/dir/writable/by/webserver/";
$mailpath .= date('Y-m-d', time()) . ".txt";
$fp = fopen($mailpath, 'w');
unset ($mailinglist);
while ($user=$DB_site->fetch_array($users)) {
echo $user[email].$septext;
$buf = $user[email] . "\n";
fputs ($fp, $buf);
flush();
}
fclose ($mailpath);
Try this...
Parker Clack
04-23-2002, 07:25 PM
Sparkz:
Thanks. That is so weird because I had tried adding the /n but it didn't work. Now it does though.
Thanks again.
Parker
Sparkz
04-23-2002, 07:34 PM
Well, /n wouldn't work, but \n would :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.