教程中国
PHOTOSHOP CS9.0中文版 MAYA 8.5 FOR WINDOWS Corel Painter v9.0 Flash MX2004 中文版 Illustrator cs2 中文版
VC++6.0含sp6 中英文版 VB6.0 +sp6 简体中文版 Borland Delphi 7汉化版 MSDN for vb6.0中文版 Visual Studio 2005简体
教程中国下属 文件存储共享专家BIBIDU.COM 提供大型软件,教材,源码,电影,音乐,图书等下载 更多精品请点此进入
  您目前所在位置: 教程中国 >> 编程基地 >> PHP >> 两个PHP发送邮件的例子 RSS订阅
两个PHP发送邮件的例子
教程(视频,书籍)下载:  ASP.NET AutoCAD 数据库 C# ASP java photoshop 网页设计 delphi 3dmax Flash C++ VB 张孝祥 实例   更多请进入BIBIDU搜索
IT搜索引擎   
   Send Mail in PHP

In this example, we will show how to send an email message to someone in PHP.


PHP Code:
<?php

echo "<html><body>";

mail ("karn@nucleus.com", "Subject", "Hello!");

echo "Sending mail...";
echo "</body></html>";

?> 

 

It is that simple!

The PHP mail function has up to four parameters. The first parameter is the recipient of the message. The second parameter is the subject of the email message. The third parameter is the body of the message. And the fourth parameter is optional, which will be covered on the next page. 

If the above example does not work when you view it in your browser then the Sendmail variable in your PHP setup file is probably not set correctly. In UNIX, it should be set to something like ’/usr/sbin/sendmail -t’. Consult your PHP documentation for more in depth instructions.


Advanced Example


Here we will show the full capabilities of the PHP mail function. 

PHP Code:
<?php

echo "<html><body>";

$recipient = "Kris Arndt <karn@nucleus.com>,npl@nucleus.com";
$subject = "Testing the mail function";
$message = "Hello!\n\nThis is the body of the message.\n\n";
$extra = "From: kris@phpworld.com\r\nReply-To: karn@nucleus.com\r\n";

mail ($recipient, $subject, $message, $extra);

echo "Sending mail...";
echo "</body></html>";

?> 

 

We send an email to two people this time, by putting two email addresses in the recipient field and separating them with commas. 

The fourth parameter holds extra headers for the email. We specify who the email was from and who the recipient should reply to. When entering multiple headers, separate them with the line feed and new line combination (’\r\n’). 

来源:编程技术-十度教育
作者:
关键字:PHP发送邮件,例子
发表日期:2006-10-18 10:32:26

网页显示有限 阅读全文请下载本文完整版WORD文档

上一篇:PHP初学者之路-认识Class   下一篇:如何使用PHP操作文件(文件读取篇)


2008-11-21 17:44:07
本文的相类似文章
  • ASP 编程中20个非常有用的例子
  • 关于使用PRO*C编程的一些简单说明和例子
  • 后台运行一个主存储过程,主存储过程通过管道同前端过程通信的例子
  • 从例子中说明oracle中关于索引的几点看法
  • 关于ORACLE性能优化的好例子
  • 完整的oracle rman备份恢复的例子
  • ORACLE存储过程管道通信的例子
  • 一个JAVA连接ORACLE的例子
  • Oracle数据库的几个关闭方法与例子
  • Logon Trigger Example 登陆例子
  • 在学习中进步 在进步中成长 教程中国相随您的成长之路
    华腾联合科技股份有限公司版权所有
    广告联系:Rosibo@163.com