Send an email in an html table

Source: Internet
Author: User

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> ";
}
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.