超级简单的发送邮件程序

来源:互联网 发布:sqlserver union all 编辑:程序博客网 时间:2024/06/03 18:17
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
最近做一个新闻系统,为了模仿各大网站的在线发信功能就写了这个小程序,希望对各位菜鸟兄弟有用。
    我没有给出一部分代码,只给出关键部分。其中shouxin代表收信人地址,shouren代表收信人姓名,jixin代表发信人地址,faren代表发信人姓名。id是前边传过来的参数,对你来说根本没什么用的。

<?
if($shouxin=="")
{
echo "没有收件人的地址,无法寄出";
}else{
$to=explode(',',$shouxin);
$tocount=count($to);
$headers ="From:".$jixin."n";
$subject="收信" ;
$body ="你好。$shouren";
$body.="n";
$body.="你的朋友$faren";
$body.="推荐您给你一篇文章 http://127.0.01.1/myweb/biye/news/newsdetail.php?id=$id ";
$body.="n";
$body.="$content";
for($i=0;$i<$tocount;$i++) {
               if(mail($to[$i], $subject, $body,$headers))
          {
            echo "发送成功!";
            }else{
             echo " 发送失败,请重新发送。";
             exit();}
        }

}
?>
转自:动态网制作指南 www.knowsky.com<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>