Home  >  Article  >  Backend Development  >  Super simple program to send emails_PHP tutorial

Super simple program to send emails_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 16:05:301127browse

Recently I was working on a news system. In order to imitate the online mail sending function of major websites, I wrote this small program. I hope it will be useful to all the newbie brothers.
I did not give part of the code, only the key parts. Among them, shouxin represents the recipient's address, shouren represents the recipient's name, jixin represents the sender's address, and faren represents the sender's name. The id is the parameter passed previously, which is of no use to you at all.

if($shouxin=="")
{
echo "Cannot send without recipient's address";
}else{
$to=explode(',',$shouxin);
$tocount=count($to);
$headers ="From:".$jixin."n";
$subject= "Receive mail";
$body="Hello.$shouren";
$body.="n";
$body.="Your friend $faren";
$body .="Recommend you an article 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) )
                                                                                                                                              
       }

}
?>




http://www.bkjia.com/PHPjc/315666.html

www.bkjia.com

http: //www.bkjia.com/PHPjc/315666.htmlTechArticleI recently made a news system. In order to imitate the online mailing function of major websites, I wrote this small program. I hope Useful for all newbie brothers. I did not give part of the code, only the details...
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