src/Smtp.php
protected function sendmail($to, $subject = '', $body = '', $mailtype = 'HTML', $cc = '', $bcc = '', $additional_headers = '')
    {

        //获取发件邮箱名称
        $from      = $this->from;
        $mail_from = $this->get_address($this->strip_comment($from));
        $body      = preg_replace('/(^|(\r\n))(\\.)/', "$1.$3", $body);
        $header    = 'MIME-Version:1.0\r\n';
        if ($mailtype == 'HTML') {
            $header .= 'Content-Type:text/html' . PHP_EOL;
        }
        $header .= 'To: ' . $to . PHP_EOL;
        if ($cc != '') {
            $header .= "Cc: " . $cc . PHP_EOL;
        }
        $header .= 'From: $from<' . $from . '>' . PHP_EOL;
        $header .= 'Subject: ' . $subject . PHP_EOL;
        $header .= $additional_headers;
        $header .= 'Date: ' . date('r') . PHP_EOL;
        $header .= 'X-Mailer:By Redhat (PHP/' . phpversion() . ')' . PHP_EOL;
        list($msec, $sec) = explode(' ', microtime());
        $header .= 'Message-ID: <' . date('YmdHis', $sec) . '.' . ($msec * 1000000) . '.' . $mail_from . '>' . PHP_EOL;
        $TO = explode(',', $this->strip_comment($to));

        if ($cc != '') {
            $TO = array_merge($TO, explode(',', $this->strip_comment($cc)));
        }
        if ($bcc != '') {
            $TO = array_merge($TO, explode(',', $this->strip_comment($bcc)));
        }

        $sent = true;
        foreach ($TO as $rcpt_to) {
            $rcpt_to = $this->get_address($rcpt_to);
            if (!$this->smtp_sockopen($rcpt_to)) {
                $this->log_write('Error: Cannot send email to ' . $rcpt_to . PHP_EOL);
                $sent = false;
                continue;
            }
            if ($this->smtp_send($this->host_name, $mail_from, $rcpt_to, $header, $body)) {
                $this->log_write('E-mail has been sent to <' . $rcpt_to . ' > ' . PHP_EOL);
            } else {
                $this->log_write('Error: Cannot send email to <' . $rcpt_to . '>' . PHP_EOL);
                $sent = false;
            }
            fclose($this->sock);
            $this->log_write('Disconnected from remote host' . PHP_EOL);
        }
        //echo "<br>";
        //echo $header;
        return $sent;
    }
protected function sendmail($to, $subject = '', $body = '', $mailtype = 'HTML', $cc = '', $bcc = '', $additional_headers = '')
    {

        //获取发件邮箱名称
        $from      = $this->from;
        $mail_from = $this->get_address($this->strip_comment($from));
        $body      = preg_replace('/(^|(\r\n))(\\.)/', "$1.$3", $body);
        $header    = 'MIME-Version:1.0\r\n';
        if ($mailtype == 'HTML') {
            $header .= 'Content-Type:text/html' . PHP_EOL;
        }
        $header .= 'To: ' . $to . PHP_EOL;
        if ($cc != '') {
            $header .= "Cc: " . $cc . PHP_EOL;
        }
        $header .= 'From: $from<' . $from . '>' . PHP_EOL;
        $header .= 'Subject: ' . $subject . PHP_EOL;
        $header .= $additional_headers;
        $header .= 'Date: ' . date('r') . PHP_EOL;
        $header .= 'X-Mailer:By Redhat (PHP/' . phpversion() . ')' . PHP_EOL;
        list($msec, $sec) = explode(' ', microtime());
        $header .= 'Message-ID: <' . date('YmdHis', $sec) . '.' . ($msec * 1000000) . '.' . $mail_from . '>' . PHP_EOL;
        $TO = explode(',', $this->strip_comment($to));

        if ($cc != '') {
            $TO = array_merge($TO, explode(',', $this->strip_comment($cc)));
        }
        if ($bcc != '') {
            $TO = array_merge($TO, explode(',', $this->strip_comment($bcc)));
        }

        $sent = true;
        foreach ($TO as $rcpt_to) {
            $rcpt_to = $this->get_address($rcpt_to);
            if (!$this->smtp_sockopen($rcpt_to)) {
                $this->log_write('Error: Cannot send email to ' . $rcpt_to . PHP_EOL);
                $sent = false;
                continue;
            }
            if ($this->smtp_send($this->host_name, $mail_from, $rcpt_to, $header, $body)) {
                $this->log_write('E-mail has been sent to <' . $rcpt_to . ' > ' . PHP_EOL);
            } else {
                $this->log_write('Error: Cannot send email to <' . $rcpt_to . '>' . PHP_EOL);
                $sent = false;
            }
            fclose($this->sock);
            $this->log_write('Disconnected from remote host' . PHP_EOL);
        }
        //echo "<br>";
        //echo $header;
        return $sent;
    }
[sendmail description]
@date   2017-10-27T14:32:38+0800
@author ChenMingjiang
@param  [type]                   $to                 [接收邮箱 多个逗号分隔]
@param  string                   $subject            [邮件标题]
@param  string                   $body               [邮件内容]
@param  [type]                   $mailtype           [description]
@param  string                   $cc                 [抄送邮箱 多个逗号分隔]
@param  string                   $bcc                [description]
@param  string                   $additional_headers [邮件格式（HTML/TXT）,TXT为文本邮件]
@return [type]                                       [description]