View Full Version : Simple Mailing List

12-30-2008, 10:26 PM
1) CODE TITLE: Simple Mailing List

2) AUTHOR NAME/NOTES: Chris Macdonald/ Nile's assistance

3) DESCRIPTION: A simple mailing list uses a text file and php files. User's can add email addresses to receive emails and can remove them from the list. The admin is the only one that can send the messages (modify access.php with username and password in $username=="" and $password=="'). Make sure to change the permissions of addresses.txt to 777 so the addresses can be added and removed by the users.


12-30-2008, 10:26 PM
Nice script. :D
1 thing though, usually when you send a mailing list, you put all the emails in BCC, that way some can't see everybody elses email that's on the mailing list.

12-30-2008, 10:39 PM
Okay I'll update this in a bit with that and I forgot to check if the email address was relatively valid (containing . & @). If anyone else can think of anything I should add in let me know.

12-30-2008, 10:46 PM
That was nice and easy to configure. How about adding an ajax interface to it?

12-30-2008, 10:49 PM
Everything you do diltony is with ajax!! Lol. What if they have it disabled?

12-30-2008, 11:21 PM
I can always revert back to

<script src="ajax.class.js"></script>
<script language="html">alert("YOU MUST ENABLE AJAX TO VIEW THIS PAGE NOW!!!!!");</script>

Crazy isnt it, fortunately most browsers support DHTML now though, google have promoted it, and so we now have ajax chat, ajax this, ajax that.......lol..........i just enjoy scripting and especially enjoy ajax, creating classes.....i have known ajax since the very begining, just that most browsers do not support it then, so i had to wait......
anyway, ajax or no ajax, the mailing list script is nice.
Maybe i should start posting php codes then. i am yet to post one yet, all i have been doing was posting ajax as if ajax is all there is to DHTML!!

12-31-2008, 12:51 AM
Okay this newer version Bcc's all contacts, verifys email address is valid, verify's the email address entered was removed from the mailing list, and allows for you to enter in your from data in the address.php file.

02-03-2009, 04:45 AM
Okay found one more bug with this. If a robot hits the page it will send out a blank email to all users by triggering the mail action. To solve this you could a) attempt to block all robots and hope a user never try's the address or b) user this code below. This is the whole code not just the part I added however if you do just want those lines its 22-27.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>

// Simple Mailing List//
//CODE COMPILED BY CHRIS MACDONALD http://www.christophermacdonald.net //
$message = $_POST['message'];
$myfile = "addresses.txt";
$fh = fopen($myfile, 'r');
$thedata = fread($fh, 20000000);
$to = '';
$subject = 'Subject test';
$headers = 'MIME-Version: 1.0' . "\r\n";
$header .= "From: youremailaddressgoeshere@yourdomain.com" . "\r\n";
$header .= $thedata . "\r\n";
if ($message == "") {
die ("Please go back and enter your message</body></html>");
else {
mail($to, $subject, $message, $header);
echo 'Mail Sent';