#native_company# #native_desc#
#native_cta#

Broadcast Email

By Joe Norman
on July 26, 2002

Version: 1

Type: Full Script

Category: Other

License: GNU General Public License

Description: When connected to a database, this page will retrieve email address al send an HTML message each. It also allows for a preview before the email is sent.

Create a file called AutoMail.php and copy the text below into the file.
-------------------------------------------------------------------------
-------------------------------------------------------------------------


<?php /* This page was wriiten by Joe Norman, www.intranet2internet.com */ ?>
<html>
<head>
<title></title>
<STYLE>
	BODY {				font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 9pt;background-color: #ffffff;SCROLLBAR-HIGHLIGHT-COLOR: #ffffff;SCROLLBAR-SHADOW-COLOR: #000000;SCROLLBAR-3DLIGHT-COLOR: #000000;SCROLLBAR-ARROW-COLOR: #ffffff;	SCROLLBAR-TRACK-COLOR: #996600;	SCROLLBAR-DARKSHADOW-COLOR: #000000;SCROLLBAR-BASE-COLOR: #336666;}
	TD, P, LI{			font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 8pt;}
	A{				font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 8pt;color:#336666;text-decoration: none;}
	A:HOVER{			font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 8pt;color:#996600;text-decoration: underline;}
	INPUT, TEXTAREA, SELECT{	font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 8pt;color: black;background: white;}
	.MENU{				font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 8pt;color: #000000;border : 1px Solid Silver;background: #ffffff;}
	H2{				font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 12pt;color: #996600;}
</STYLE>
</head>
<BODY>
<?php

if(empty($SEND)){$SEND="";}

switch($SEND){
	case "Send":
		if(!empty($MESSAGE)){
			if(empty($SUBJECT)){$SUBJECT=""};
			$HEADERS  = "MIME-Version: 1.0rn";
			$HEADERS .= "Content-type: text/html; charset=iso-8859-1rn";
			$HEADERS .= "From: Info <[ REPLY EMAIL ADDRESS ]>rn";
			/* [ REPLY EMAIL ADDRESS] should be replaced with the appropriate email address */

			/* This script is based on pulling email addresses from a MySQL user database The code below should be changed to the appropriate information */
			

			$linkID = mysql_connect([hostname [:port] [:path/to/socket], [username], [password]);
			mysql_select_db([database], $linkID);

			$obRS = mysql_query("SELECT email FROM users", $linkID);
		
			while($row = mysql_fetch_row($obRS)){
				foreach ($row as $field){
					mail($field, $SUBJECT, $MESSAGE, $HEADERS);
					print "Message sent to: <b>$field</b><br>";
				}
			}

			mysql_close($linkID);
			print "<hr><b>MESSAGE DETAILS</b><hr>";
			print "<b>Subject:</b> $SUBJECT<br>";
			print "<b>Message:</b><p>$MESSAGE";
		}
		break;
	case "Preview":
		print "<TABLE BORDER=1 CELLSPACING=0 WIDTH=100% ><TR><TD VALIGN=TOP>$MESSAGE</TD>";
		print "<TD VALIGN=TOP><FORM ACTION=AutoMail.php  METHOD=POST NAME=FORM1 >";
		print "<B>SUBJECT: </B><Input TYPE=TEXT NAME=SUBJECT VALUE='$SUBJECT' ><BR>";
		print "<TEXTAREA NAME=MESSAGE STYLE='width:500;height:300' WRAP=off  >$MESSAGE</TEXTAREA><BR>";
		print "<INPUT TYPE=SUBMIT VALUE=Preview NAME=SEND > <INPUT TYPE=BUTTON ONCLICK="document.FORM1.MESSAGE.value=''" VALUE=Reset >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT TYPE=SUBMIT VALUE=Send NAME=SEND > ";
		print "</FORM></TD></TR></TABLE>";
		break;
	default:
		print "<FORM ACTION=AutoMail.php  METHOD=POST NAME=FORM1 >";
		print "<B>SUBJECT: </B><Input TYPE=TEXT NAME=SUBJECT VALUE='' ><BR>";
		print "Please type in html code below.<BR>";
		print "<TEXTAREA NAME=MESSAGE STYLE='width:500;height:300' WRAP=off  ></TEXTAREA><BR>";
		print "<INPUT TYPE=SUBMIT VALUE=Preview NAME=SEND > <INPUT TYPE=BUTTON ONCLICK="document.FORM1.MESSAGE.value=''" VALUE=Reset >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT TYPE=SUBMIT VALUE=Send NAME=SEND > ";
		print "</FORM>";
}

?>
</BODY></HTML>