コード例 #1
0
ファイル: Mail.class.php プロジェクト: sysuzjz/soya
	 * @param string mailto address
	 * @param string mail content
	 * @param array word replace rules
	 *
	 */
    public static function autosend($mailto, $content, $replace = null)
    {
        foreach ($replace as $k => $v) {
            $content = str_replace($k, $v, $content);
        }
        $to = array();
        if (is_string($mailto)) {
            $to[0] = $mailto;
        }
        assert(trim($mailto) == '');
        Mail::_send($to, $content);
    }
    /**
	 * Basic send function.
	 * @param array mailto list
	 * @param string content
	 * @param array attachment path list
	 */
    private static function _send($mailto, $content, $title = '', $attachment = null)
    {
        require_once 'phpmailer/class.phpmailer.php';
        #echo "Begin!<br/>";
        if ($title == '') {
            $title = '来自IBM Power大赛官方的自动邮件,请勿直接回复本邮件。';
        }
        $mail = new phpmailer();
        // defaults to using php "mail()"
        $mail->IsSmtp();
        // telling the class to use SendMail transport
        #$body = 'hello cxj!<br/>';
        #$body = eregi_replace("[\]",'',$body);
        $config = C('PHPMAILER');
        $address = $config['FROM'];
        $password = $config['PASSWORD'];
        $smtp = $config['HOST'];
        $port = $config['PORT'];
        #$mail->AddReplyTo($address,"First Last");
        foreach ($mailto as $m) {
            $mail->AddAddress($m, "Power大赛参赛选手 {$m} ");
        }
        $mail->SMTPAuth = true;
        //$mail->from = $address;
        //$mail->to = $address;
        $mail->smtpsecure = 'ssl';
        $mail->From = $address;