我想从Yii框架中的简单联系表单发送电子邮件,这是我第一次处理这样的案例,这是我的代码:
public function actionContact()
{
$model=new ContactForm;
if(isset($_POST['ContactForm']))
{
$model->attributes=$_POST['ContactForm'];
if($model->validate())
{
$name='=?UTF-8?B?'.base64_encode($model->name).'?=';
$subject='=?UTF-8?B?'.base64_encode($model->subject).'?=';
$headers="From: $name <{$model->email}>\r\n".
"Reply-To: {$model->email}\r\n".
"MIME-Version: 1.0\r\n".
"Content-type: text/plain; charset=UTF-8";
ini_set("SMTP","mail.patrahr.com");
ini_set("smtp_port","25");
mail(Yii::app()->params['info@patrahr.com'],$subject,$model->body,$headers);
Yii::app()->user->setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible.');
$this->refresh();
}
}
$this->render('contact_1',array('model'=>$model));
}
但是我收到了一个错误:
mail(): SMTP server response: 550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1)
那为什么会出现这个错误?