当前位置: 首页 > 图文教程 > 网络编程 > PHP > 通过html表格发电子邮件

PHP
搜索和替换文件或目录的一个好类--很实用
树型结构列出指定目录里所有文件的PHP类
使用字符串函数输出整数化的PHP版本号
php录入页面中动态从数据库中提取数据的实现
定制404错误页面,并发信给管理员的程序
让你的PHP同时支持GIF、png、JPEG
一个颜色轮换的简单例子
二十行语句实现从Excel到mysql的转化
模仿OSO的论坛(四)
简体中文转换为繁体中文的PHP函数
繁体中文转换为简体中文的PHP函数
PHP安装攻略:常见问题解答(三)
基于数据库的在线人数,日访问量等统计
NO3第三帝国留言簿制作过程
一个没有MYSQL数据库支持的简易留言本的编写
PHP安装攻略:常见问题解答(二)
在windows iis5下安装php4.0+mysql之我见
PHP聊天室技术
利用PHP实现与ASP Banner组件相似的类
PHP安装攻略:常见问题解答(一)

PHP 中的 通过html表格发电子邮件


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 119 ::
收藏到网摘: n/a

如下:
<?
/******************************************************************************
Description: This is a simple script to send emails via a html-form
to different users
Date : 1999-02-25
Author : amalesh kempf <[email protected]>

Create this table
The field "what" is for different categories
CREATE TABLE email_notify (
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="[email protected]";

if (!$btnSendEmail)
{
?>
The email will be added automatically with "Hello Name" in the first line of
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_notify where lcase(what) =
'$strWhat'";
$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\n" . $strBody;
// Email
mail($strEmail,$strSubject,$strBodyComplete,$strHeader);
// Output
echo "Send to $strName<br>";
}
}
?>