龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

php发邮件给多人

时间:2014-06-19 02:16来源:网络整理 作者:网络 点击:
分享到:
php发邮件给多人 **php发邮件给多人****[PHP]代码**```{.php}//class.emailer.phpclass Emailer{ private $sender; private $recipients; private $subject; private $body; function __construct($sender)

php发邮件给多人

[PHP]代码

//class.emailer.php
class Emailer
{
  private $sender;
  private $recipients;
  private $subject;
  private $body;
  function __construct($sender)
  {
    $this->sender = $sender;
    $this->recipients = array();
  }
  public function addRecipients($recipient)
  { 
    array_push($this->recipients, $recipient);
  }
  public function setSubject($subject)
  {
    $this->subject = $subject;
  }
  public function setBody($body)
  {
    $this->body = $body;
  }
  public function sendEmail()
  {
    foreach ($this->recipients as $recipient)
    {
      $result = mail($recipient, $this->subject, $this->body,
        "From: {$this->sender}\r\n");
      if ($result) echo "Mail successfully sent to {$recipient}<br/>";
    }
  }
}
精彩图集

赞助商链接