我正在尝试使用 CakeEmail 发送一封电子邮件,但它在$email->to()
方法上失败了。可以在此图像上看到错误消息:http: //i47.tinypic.com/240yq86.png
基本上,我收到这两个错误:
Warning (2): preg_match() expects parameter 2 to be string, object given [CORE/Cake/Utility/Validation.php, line 815]
Warning (4096): Object of class CakeEmail could not be converted to string [CORE/Cake/basics.php, line 566]
这是我的sendEmail()
方法:
function sendEmail($id, $email, $token)
{
print_r($email);
$email = new CakeEmail();
$email->from('admin@gmail.com');
$email->to($email);
$email->subject('Activate your account');
$activate_url = 'http://' . env('SERVER_NAME') .'/users/activate/'.$id.'/'.$token;
$message = "Thank you for signing up. Click on the activation link to activate your account \n";
return $email->send($message.$activate_url);
}