| 首页 | IT动态 | 硬件 | 应用 | 互联网 | 网络 | 网站 | 黑客 | 编程 | 数码 | 视频教程 | 游戏 | 休闲 | 软件 | 视频 | IT认证 | 动漫图片 | IT杂谈 | 论坛 | 
Google
专 题 栏 目
最 新 热 门
最 新 推 荐
相 关 文 章
  • 一个form两个提交按钮,分别提…

  • 网站建设的五个条件 有流量才…

  • 学网页设计与网页制作该注意…

  • ASP.NET2.0中控件的简单异步…

  • 实例:ASP.NET遍历配置文件的…

  • Asp.net生成htm静态文件的两…

  • 一个无刷新效果定时自动更新…

  • 小例子:ASP.NET定制简单的错…

  • 用.net 处理xmlHttp发送异步…

  • 技巧:ASP.Net 2.0 发送邮件…

  • 广 告 位 置
    黄金广告位
    Q
    您现在的位置: 无忧IT人 >> 网站 >> php >> 文章正文
    两个PHP发送邮件的例子         
    两个PHP发送邮件的例子
    作者:网络 文章来源:转载 点击数: 更新时间:2005-8-13
    [ 字体:缩小 正常 放大 | 双击自动滚屏 ]
    请选择合适的字体颜色:


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

    [1]

    文章录入:小秦    责任编辑:小秦 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    | 设为首页 | 加入收藏 | 联系站长 | 关于我们 | 友情链接 | 版权申明 |