laravel5.5 ajax post,邮件不是从ajax post请求发送laravel 5(Mail not sending in laravel 5 from an ajax post req...

I am working on forgot password functionality in my laravel 5.0 application. I am asking user to enter registered email and submit(post method) this form works on jquery ajax post request. After getting email from request i am checking it in db whether it exist or not. if exist i am updating new password, if not sending an error message upto this every this is fine. Now i am trying to send email with new password to the user, it is not working. Password is updating but email not sending.Find my controller code below

public function forgot_pass(Request $request){

$email = $request->input('femail');

$data = ['email' => $email];

$user = Myuser::where($data)->count();

if($user == 0){

return response()->json(['status' => 'Invalid']);

}

else{

$user_details = Myuser::where($data)->get()->first();

$new_pass = $this->generateRandomString();

$md5_pass = md5("EEE".$new_pass);

$status = Myuser::where('email', $email)

->update(['pass' => $md5_pass]);

if($status){

$mail_data = ['name' => $user_details->name, 'new_pass' => $new_pass];

Mail::send('emails.newpassword', $mail_data, function($message)

{

$message->from('us@example.com', 'Laravel');

$message->to($email);

});

return response()->json(['status' => 'Invalid']);

}

}

}

Actually mail is working if i used $message->to('sometest@testmail.com'); instead of $message->to($email);. Below is the error i am getting.

0v2uI.jpg

Feeling strange why $email causing error.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值