• 16862阅读
  • 0回复

【原创】用PHP mail()函数发送发送HTML格式的电子邮件 [复制链接]

上一主题 下一主题
离线XChinux
 

只看楼主 倒序阅读 楼主  发表于: 2005-06-25
<?php
if (isset($_POST['submit']))
{
    $mailto = $_POST['mailto'];
    $subject = $_POST['subject'];
    $message = $_POST['message'];

    if (strlen($mailto) < 1)
    {
          $tip_mailto = "电子邮件不能为空";
    }
else
    if (strlen($subject) < 1)
    {
          $tip_subject = "主题不能为空";
    }
else
    if (strlen($message) < 1)
    {
          $tip_message = "内容不能为空";
    }
else
{
    $header = "From: XChinux<hakusan@sohu.com>\r\n" .
          "Reply-To: hakusan@sohu.com\r\n" .
          "X-Mailer: PHP/" . phpversion() . "\r\n" .
          "MIME-Version: 1.0\r\n" .
          "Content-type: text/html; charset=gb2312\r\n";

    $ret = mail($mailto, $subject, $message, $header);
    if ($ret)
    {
          $tip_info = "发送成功";
    }
}
}
?>
<html>
<head>
</head>
<body>
网络邮件发送系统
<form name="formMail" action="mail.php" method="POST">
<?=$tip_info?>

发送给谁:<input type="text" name="mailto" value=""><?=$tip_mailto?>

邮件主题:<input type="text" name="subject" value-""><?=$tip_subject?>

邮件内容:<textarea name="message" cols="60" rows="10"></textarea><?=$tip_message?>

<input type="submit" value="发送" name="submit">
</form>
</body>
</html>
[ 此贴被XChinux在2005-08-23 19:57重新编辑 ]
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
快速回复
限100 字节
 
上一个 下一个