Laravel 不会发送电子邮件

Laravel won't send email

我已经设置了我的电子邮件功能,我可以获取我的表单数据但无法发送它们,

我收到错误

Undefined variable: name 

我的表单数据dd

array:6 [▼
  "name" => "tester"
  "email" => "test@test.com"
  "subject" => "testing emails"
  "issue" => "Other"
  "budget" => "100"
  "messagetext" => "hello there,"
]

代码

My function

public function sendemailtoadmin(Request $request){

        $this->validate($request, array(
        'name' => 'required|max:255',
        'email' => 'required|email',
        'issue' => 'required',
        'budget' => 'nullable|numeric',
        'messagetext' => 'required|min:10|max:15000|string',
        'subject' => 'required',
      ));

      $data = array(
        'name' => $request->name,
        'email' => $request->email,
        'subject' => $request->subject,
        'issue' => $request->issue,
        'budget' => $request->budget,
        'messagetext' => $request->messagetext,
      );

      Mail::send(new ContactForm(), $data, function($message) use ($data) {
        $message->from($data['email']);
        $message->to('xxxx@xxxx.com');
        $message->subject($data['subject']);
      });

      Session::flash('flash_message', 'Your Email was sent. We will contact you shortly.');
      return redirect()->back();
    }

My email template

@component('mail::message')

<p>
Name :{{ $name}}<br>
Email address : {{ $email }}<br>
Type of issue: {{ $issue}}<br>
Subject : {{ $subject }}<br>
Budget : {{ $budget }}<br>
Message : {{ $messagetext}}
</p>


Thanks,<br>
{{ config('app.name') }}
@endcomponent

有什么想法吗?

电子邮件模板中应该有 {{ $data['name'] }},而不是 {{ $name }}。
这同样适用于模板中的所有变量,$email,$issue,...。

已解决

我已将 new ContactForm() 更改为 'my.view.address' 并使用 HTML view 而不是 markdown。