php专区

 首页 > php专区 > PHP应用 > 常用功能 > 通过html表格发电子邮件-PHP实例

通过html表格发电子邮件-PHP实例

分享到:
【字体:
导读:
          通过html表格发电子邮件,如下:lt;?nbsp;nbsp;/******************************************************************************nbsp;nbsp;Description:Thisisasimplescripttosendemailsviaahtml-formnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;n...

如下:

/******************************************************************************  
Description: This is a simple script to send emails via a html-form   
               to different users  
Date        : 1999-02-25  
Author        : amalesh kempf   


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="you@domain.com";  



if (!$btnSendEmail)  
{  
?>  

The email will be added automatically with "Hello Name" in the first line of   
the emailbody!
  

  

    
  
      
          
              
              
          
          
              
              
          
          
              
              
          
    
Subject
Body
Category  
                  
            
  
     type="submit" value="Sende email">  
    
  
      
}  


if (isset($btnSendEmail))  
{    echo "Send Email
";  

    // Create connection  
    $intConID = MySQL_pconnect($strHost,$strUser,$strPassw);  

    // Header  
    $strHeader = "Return-Path: $strSendernErrors-To: $strSendernFrom:   
$strSender";  
      
    // SQL  
    $strSQL = "select name,email from email_notify where lcase(what) =   
'$strWhat'";  
    $intRes = mysql_query($strSQL,$intConID);  

    echo "Send Email $strBody
";  

    // fetch array      
    while($saRow = mysql_fetch_array($intRes))  
    {    $strEmail = $saRow["email"];  
        $strName = $saRow["name"];  
        $strBodyComplete = "Hello " . $strName[$i] . "!nn" . $strBody;  
          
        // Email  
        mail($strEmail,$strSubject,$strBodyComplete,$strHeader);  
          
        // Output  
        echo "Send to $strName
";  
    }  
}  
?>  
分享到:
一个简单的自动发送邮件系统(一)-PHP实例
一个简单的自动发送邮件系统     php的另一个强大的特征就是他有能通过html的表单修改变量的能力,通过这些变量,我们可以实现很多任务,包括象:发送wed-based的邮件,把信息输出给屏幕,从数据库中读取和传递数据。下面让我们构建一个小型的自动发送邮件系统,来演示这个能力。     让我们假设有这样一个html的...
一个php作的文本留言本的例子(一)-PHP实...
大家知道,数据库对于网络来说的重要性.由于cgi的复杂,现在asp和php+MySQL已经成为主流.几乎所有的个人网页都要用到留言本,可是申请的留言本很不稳定.这为网上的交流带来了诸多不便.所以,希望拥有自己的留言本的朋友越来越多. 但是,免费的个人主页支持asp和php的很少.笔者现在向您推荐奥索网,(http://www.oso.com.cn)支持ph...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……