Answer the question
In order to leave comments, you need to log in
How to send form data to email in Laravel?
There is a feedback form.
<form action="{{ route('send') }}" method="post">
@csrf
<div class="form-group">
<label for="name">Ваше имя</label>
<input type="text" name="name" placeholder="Введите имя">
</div>
<div>
<label for="email">Ваша почта</label>
<input type="text" name="email" placeholder="Напишите вашу почту">
</div>
<div >
<label for="phone">Ваш номер телефона</label>
<input type="text" name="phone" placeholder="Напишите ваш номер телефона">
</div>
<button type="submit">Отправить</button>
</form>
namespace App\Http\Controllers;
use App\Contact;
use Illuminate\Http\Request;
use App\Http\Requests\ContactRequest;
use Mail;
class ContactController extends Controller
{
public function send (Request $req){
$firstname = $req->input('name');
mail::send(['mailtest' , ['firstname' => $firstname] ], ['name' => 'ARTEM'], function($message) use ($firstname) {
$message->to('[email protected]', 'ARTEM')->subject('test email');
});
}
Answer the question
In order to leave comments, you need to log in
artisan make:mail
will generate a Mailable class and template for you.
All public fields of this class will be available in the template as variables.
To send, just call
Mail::to($user->email)
->send(new RegistrationMail($user));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question