| 网站首页 | 硬件维修 | 应用学院 | 网络组建 | 网站制作 | 菜鸟黑客 | 编程之道 | 数码大全 | 娱乐休闲 | 软件下载 | 在线视频 | 请您留言 | 技术论坛 | 
专 题 栏 目
最 新 热 门
最 新 推 荐
相 关 文 章
  • PHP与javascript对多项选…

  • 在html文件引入其它html文件…

  • 发现CSS控件的好处

  • CSS滤镜之FlipH、FlipV属性

  • CSS滤镜之alpha属性

  • *.HTC 文件的简单介绍

  • CSS滤镜:alpha属性

  • CSS滤镜:FlipH、FlipV属性

  • CSS滤镜之alpha属性

  • CSS滤镜之FlipH、FlipV属性

  • 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条。评论内容只代表网友观点,与本站立场无关!)
    | 设为首页 | 加入收藏 | 联系站长 | 关于我们 | 友情链接 | 版权申明 |