S
S
Sergey Zavialov2019-04-21 10:26:30
Email
Sergey Zavialov, 2019-04-21 10:26:30

How to send email?

controller

$data = $request->all();
      
      $result = Mail::send('site.email',['data'=>$data], function($message) use ($data) {
        
        $mail_admin = env('MAIL_ADMIN');
        
        $message->from($data['email'],$data['name']);  
        $message->to($mail_admin,'Mr. Admin')->subject('Question'); 
    
      });
  
      if($result) {
        return redirect()->route('home')->with('status', 'Email is send');
      }

env
MAIL_DRIVER=mail
MAIL_HOST=
MAIL_PORT=
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=

[email protected]

email.blade
<h1> {{ $data['name'] }} </h1>
<div>{{ $data['text'] }}</div>

When sending a mail, an error occurs Address in mailbox given [] does not comply with RFC 2822, 3.6.2.
What is causing this error and how can I fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Shitskov, 2019-04-21
@Zarom

An error due to the fact that you have invalid information in one of the headers, for example from or to. Check the validity of variables and finalized headers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question