在 yii 中,我正在创建 sendemail 功能。在进行 SMTP 的所有设置后,我正在使用邮件扩展程序及其正常工作。我在控制器中将方法 actionEmail 设置为-
public function actionEmail()
{
$model=new User;
$mailer = Yii::createComponent('application.extensions.mailer.EMailer');
$mailer->IsSMTP();
$mailer->IsHTML(true);
$mailer->SMTPAuth = true;
$mailer->SMTPSecure = "ssl";
$mailer->Host = "smtp.gmail.com";
$mailer->Port = 465;
$mailer->CharSet = 'UTF-8';
$mailer->Username = "abc@gmail.com";
$mailer->Password = "abc";
$mailer->From = "xyz@gmail.com";
$mailer->FromName = "Balaee.com";
$mailer->AddAddress('shilpa.kirad@shailani.com');
$mailer->Subject = "welcome to Balaee";
$mailer->IsHTML(true);
// $html = $this->renderPartial('myview',array('content'=>'Hello World'),true);
$mailer->正文 = "
欢迎
单击链接以获取其他详细信息 ".$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if($mailer->Send()) {
echo "Please check mail";
//Yii::app()->user->setFlash('register','Thank you for contacting us. We will respond to you as soon as possible.');
// $this->refresh();
}
else {
echo "Fail to send your message!";
}
}
此方法执行正确。它正在将邮件发送到 mailer->AddAdress 中提到的地址。但是现在我想从与特定用户 ID 对应的数据库中检索电子邮件 ID 并将邮件发送给他。即我不想为此字段插入硬编码值。那么我该怎么做。请帮我。