# How to send mail with Laravel?
1. Define the email address for your website in the configuration file config/constants.php.
return [
'FROM_MAIL' => 'my_email@my_site.com',
'FROM_MAIL_NAME' => 'my_website_name',
];
2. In the method from which you want to send the email, collect the data that you want to send into an array, and pass this into the method Mail::send.
$emailData = [
'id' => $id,
'name' => $data['name'],
'email' => $data['email'],
'text' => $data['description'],
];
\Mail::send('emails.new_msg', $emailData, function ($message) use ($emailData) {
$message->from(config('constants.FROM_MAIL'), config('constants.FROM_MAIL_NAME'));
$message->to($emailData['email']);
$msgSubject = "New message id #" . $emailData['id'];
$message->subject($msgSubject);
});
3. Embed the items keys from the above array as variables in your email's template:
Id: {{$id}}
Name: {{$name}}
Email: {{$email}}
Description: {{$text}}