yxmjc 2011-06-19 10:45:32 4068次浏览 4条回复 0 0 0
public function sendEmail($params = array())
{
    $params = array(
        'smtpHost'=>'smtp.qq.com',
        'fromAddress'=>'admin@yxol.org',    //我用的是qq的域名邮箱
        'myname'=>'Yxol.org',
        'sendPassword'=>'*******',
        'replyAddress'=>'admin@yxol.org',
        'sendAddress'=>'9583738@qq.com',
        'title'=>'测试...',
        'content'=>'内容...',
    );
    if (is_array($params) && !empty($params)) 
    {
        Yii::app()->mailer->Host = $params['smtpHost'];
        Yii::app()->mailer->IsSMTP();
        Yii::app()->mailer->From = $params['fromAddress'];
        Yii::app()->mailer->FromName = $params['myname'];
        Yii::app()->mailer->Password = $params['sendPassword'];
        Yii::app()->mailer->SMTPDebug = true;
        Yii::app()->mailer->AddReplyTo($params['replyAddress']);
        Yii::app()->mailer->AddAddress($params['sendAddress']);
        Yii::app()->mailer->Subject = $params['title'];
        Yii::app()->mailer->Body = $params['content'];
        if(!Yii::app()->mailer->Send())
        {
            return false;
        }
        else
        {
            return true;
        }
    }
    else
    {
        return false;
    }
}

提示出错内容: Could not instantiate mail function. 邮件发送失败. 错误原因: Could not instantiate mail function.

您需要登录后才可以回复。登录 | 立即注册