Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 网站建设 > PHP > 两个PHP发送邮件的例子
【标  题】:两个PHP发送邮件的例子
【关键字】:PHP,HP,PHP
【来  源】:网络

两个PHP发送邮件的例子

Your Ad Here


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').

NT下基于邮件服务软件(IMAIL)的邮件发送程序--(网络版):【上一篇】
“收发”邮件的一个程序:【下一篇】
【相关文章】
  • PHP邮件专题(1)
  • PHP邮件专题(2)
  • 功能齐全的发送PHP邮件类
  • 使用php的编码功能-问题发现
  • 使用php的编码功能-mime.inc
  • 支持PHP的文本编辑器
  • 建立灵巧结构的PHP程序
  • PHP中利用GD输出汉字实例
  • 用Yaapi和PHP构建一个简单的内容管理系统
  • 说说PHP作图
  • 【随机文章】
  • Linux 用户(User)查询篇
  • XForm + Ajax
  • FTP架站方法
  • 书籍介绍-《Web性能测试实战》
  • sun Application Server 学习笔记
  • 要买惠普R607
  • 3DS MAX命令翻译 (初学者的速查手册)(2)
  • SQL安装问题(一)
  • Forum 2.0 latest 的安装
  • maven使用系列文章-(1)
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.