Reputation: 305
my focus is to send an email with a form where you can insert: name, last name, from(any email), to (my email). First of all I have tried using the google configuration(see on internet), but the email don't send, the result is a blank page. I must configuration only services.php and .env ?
Upvotes: 0
Views: 1152
Reputation: 3220
Nothing too complicated, have you read the docs?
First of all you need to setup your configuration inside config/mail.php
(as 'driver'
) or in your .env
(as MAIL_DRIVER
).
You may start setting it to sendmail
, but consider using smtp
or a service like mailgun as soon as you go online.
Second step is the creation of a view, as example in app/resources/views/emails
(the snippet that follows would use app/resources/views/emails/reminder.blade.php
), however you can name it whatever you prefer.
Then in your controller all you have to do is just:
$email = '[email protected]';
$name = 'John Doe';
Mail::send('emails.reminder', [], function ($m) {
$m->from('[email protected]', 'Your Application');
$m->to($email, $name)->subject('Your Reminder!');
});
Where the array passed as second argument may contain additional data that you may want to pass to the view.
// EDIT Sorry, I didn't understand you meant to use gmail.
In that case you may need to configure smtp settings. As an example, if you would use .env
for settings it should reflect something like:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=mybeautifulpasswordthatnooneknows
MAIL_ENCRYPTION=tls
Upvotes: 1