Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my code:
- Routes.php
- Route::get('/sendbasicemai','MailController@basic_email');
- i change in .env file as below
- MAIL_DRIVER=smtp
- MAIL_HOST=smtp.gmail.com
- MAIL_PORT=465
- MAIL_USERNAME=abx.xyz@gmail.com
- MAIL_PASSWORD=******
- MAIL_ENCRYPTION=null
- and in config.php
- array (
- 'driver' => 'smtp',
- 'host' => 'smtp.gmail.com',
- 'port' => '465',
- 'from' =>
- array (
- 'address' => NULL,
- 'name' => NULL,
- ),
- 'encryption' => NULL,
- 'username' => 'abc.xyz@gmail.com',
- 'password' => '*********',
- 'sendmail' => '/usr/sbin/sendmail -bs',
- 'pretend' => false,
- ),
- MailController.php
- namespace AppHttpControllers;
- use IlluminateHttpRequest;
- use Mail;
- use AppHttpRequests;
- use AppHttpControllersController;
- class MailController extends Controller
- {
- public function basic_email(){
- $data = array('name'=>"Virat Gandhi");
- Mail::send(['text'=>'mail'], $data, function($message) {
- $message->to('abc@xyz.in', 'Tutorials Point')->subject
- ('Laravel Basic Testing Mail');
- $message->from('abc.xyz@gmail.com','Virat Gandhi');
- });
- echo "Basic Email Sent. Check your inbox.";
- }
- }
- Mail.blade.php
- <h1>Hi, {{ $name }}</h1>
- <p>Sending Mail from Laravel.</p>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement