Home >php教程 >php手册 >超级简单的发送邮件程序

超级简单的发送邮件程序

WBOY
WBOYOriginal
2016-06-21 09:03:45822browse
最近做一个新闻系统,为了模仿各大网站的在线发信功能就写了这个小程序,希望对各位菜鸟兄弟有用。
    我没有给出一部分代码,只给出关键部分。其中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               if(mail($to[$i], $subject, $body,$headers))
          {
            echo "发送成功!";
            }else{
             echo " 发送失败,请重新发送。";
             exit();}
        }

}
?>
转自:动态网制作指南 www.knowsky.com



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn