Laravel 5 adding HTML to email

后端 未结 4 1009
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-31 00:01

I\'m currently trying to create a HTML email in Laravel 5 and I have some text (which contains
elements) I want to insert in the email. I use the fo

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-31 00:32

    After checking various solutions, following codes worked for me -

     try {
          $template_data = ['otp' => $otp, 'name' => $name];
          //send verification code
          Mail::send(['html' => 'email.account_verification'], $template_data,
                    function ($message) use ($email) {
                       $message->to($email)
                       ->from('test@yourdamin.com') //not sure why I have to add this
                       ->subject('Account verification');
          });
    
          return Response::json(['code' => 200, 'msg' => 'Sent successfully']);
    
          } catch (Exception $ex) {
                return Response::json(['code' => 200, 'msg' => 'Something went wrong, please try later.']);
          }  
    

提交回复
热议问题