Home > Article > Backend Development > Super simple program to send emails_PHP tutorial
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