I want to send an email to my email when a user views a page.
I have done this successfully.
My code is as follows:
Route::any('contact_us/send', function() {
return Mail::send('contactus.send', ['name' => 'Advaith'], function($message) {
$name = $_POST['name'];
$from = $_POST['email'];
$message->to('itsme@gmail.com')->from($from, $name)->subject('Feed Back');
});
});
This code sends email to my account.
But he did not send the sender's name and e-mail address ( $nameand $from)
I even tried to change the variables and give him an example of e-mail.
My file is .envas follows:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=itsme@gmail.com
MAIL_PASSWORD=**********
MAIL_ENCRYPTION=tls
My file is config/mail.phpas follows:
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => 'hello@example.com',
'name' => 'Example',
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
My form that submits data is as follows:
<form class="ad-form col-md-12" method="POST" action="/contact_us/send">
{{ csrf_field() }}
<input placeholder="Name...*" type="text" name="name" required="required">
<br>
<input placeholder="Email...*" type="email" name="email" required="required">
<br>
<textarea required="required" placeholder="Your valuable feedback...*" name="comment" rows="5" cols="40"></textarea>
<br>
<input type="submit" name="submit" value="Send">
</form>
And my file is contactus/send.blade.phpas follows:
<div style="border: 2px solid orange; padding: 30px;">
<div>From: <b>{{ $_POST['name'] }}</b></div>
<div>From-Email: <b>{{ $_POST['email'] }}</b><hr></div><br>
<div style="text-align: justify;"><strong>{{ $_POST['comment'] }}</strong></div>
</div>
Please tell me why it does not send the address.
And please tell me how to go to another page after sending the email.