-
Every time I pass data to the email view using
Here is what I did:
class ContactUs extends Mailable
{
use Queueable, SerializesModels;
protected string $name;
protected string $email;
protected string $message;
public function __construct($data = [])
{
if(!empty($data)){
$this->name = $data['name'];
$this->email = $data['email'];
$this->message = $data['message'];
}
}
public function build()
{
return $this->view('mails.contact')
->text('mails.contact')
->with([
'name' => $this->name,
'email' => $this->email,
'message' => $this->message
]);
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div>
<div>
<p>sender name: {{ $name }}</p>
<p>sender email: {{ $email }}</p>
</div>
{{ $message }}
</div>
</body>
</html> According to laravel documentation, That is the way they are passing data to the email template. |
Beta Was this translation helpful? Give feedback.
Answered by
exxxar
Dec 12, 2022
Replies: 1 comment
-
change $message to $text or on another |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
cris-m
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
change $message to $text or on another