As follows:
<?
/*************************************** ***************************************
Description: This is a simple script to send emails via a html-form
To different users
Date:
Author: amalesh kempf <amalesh@goatrance.de>
Create this table
The field "what" is for different categories
Create table email_policy (
ID int (11) DEFAULT '0' not null,
What varchar (60) DEFAULT '0' not null,
Name varchar (60) DEFAULT '0' not null,
Email varchar (60) DEFAULT '0' not null,
Timestamp varchar (16 ),
KEY (What ),
Primary key (ID ));
To fill this table you might create an insert form
**************************************** ***************************************/
// Set this values:
$ StrHost = "localhost ";
$ StrUser = "root ";
$ StrPassw = "";
$ StrSender = "you@domain.com ";
If (! $ BtnSendEmail)
{
?>
The email will be added automatically with "Hello Name" in the first line
The emailbody! <Br>
<Br>
<Form action = "send_email.php3" enctype = "application/x-www-form-
Urlencoded "method =" post ">
<Table>
<Tr>
<Td> Subject </td>
<Td> <input name = "strSubject" size = "40"> </td>
</Tr>
<Tr>
<Td> Body </td>
<Td> <textarea cols = "40" name = "strBody" rows = "8"
Wrap = "PHYSICAL"> <? Echo $ strBody?> </Textarea> </td>
</Tr>
<Tr>
<Td> Category </td>
<Td>
<Select name = "strWhat">
<? Php // add you categories here:?>
<Option value = "party"> Party </option>
</Select>
</Td>
</Tr>
</Table>
<Input name = "btnSendEmail" style = "HEIGHT: 24px; WIDTH: 224px"
Type = "submit" value = "Sende email">
</Form>
<? Php
}
If (isset ($ btnSendEmail ))
{Echo "Send Email <br> ";
// Create connection
$ IntConID = mysql_pconnect ($ strHost, $ strUser, $ strPassw );
// Header
$ StrHeader = "Return-Path: $ strSender \ nErrors-To: $ strSender \ nFrom:
$ StrSender ";
// SQL
$ StrSQL = "select name, email from email_policy where lcase (what) =
'$ Strwh '";
$ IntRes = mysql_query ($ strSQL, $ intConID );
Echo "Send Email $ strBody <br> ";
// Fetch array
While ($ saRow = mysql_fetch_array ($ intRes ))
{$ StrEmail = $ saRow ["email"];
$ StrName = $ saRow ["name"];
$ StrBodyComplete = "Hello". $ strName [$ I]. "! \ N ". $ strBody;
// Email
Mail ($ strEmail, $ strSubject, $ strBodyComplete, $ strHeader );
// Output
Echo "Send to $ strName <br> ";
}
}
?>