Advertisement
Guest User

Untitled

a guest
Mar 14th, 2017
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. my code:
  2. Routes.php
  3. Route::get('/sendbasicemai','MailController@basic_email');
  4.  
  5. i change in .env file as below
  6. MAIL_DRIVER=smtp
  7. MAIL_HOST=smtp.gmail.com
  8. MAIL_PORT=465
  9. MAIL_USERNAME=abx.xyz@gmail.com
  10. MAIL_PASSWORD=******
  11. MAIL_ENCRYPTION=null
  12.  
  13. and in config.php
  14. array (
  15. 'driver' => 'smtp',
  16. 'host' => 'smtp.gmail.com',
  17. 'port' => '465',
  18. 'from' =>
  19. array (
  20. 'address' => NULL,
  21. 'name' => NULL,
  22. ),
  23. 'encryption' => NULL,
  24. 'username' => 'abc.xyz@gmail.com',
  25. 'password' => '*********',
  26. 'sendmail' => '/usr/sbin/sendmail -bs',
  27. 'pretend' => false,
  28. ),
  29.  
  30. MailController.php
  31.  
  32. namespace AppHttpControllers;
  33.  
  34. use IlluminateHttpRequest;
  35. use Mail;
  36. use AppHttpRequests;
  37. use AppHttpControllersController;
  38.  
  39. class MailController extends Controller
  40. {
  41. public function basic_email(){
  42. $data = array('name'=>"Virat Gandhi");
  43.  
  44. Mail::send(['text'=>'mail'], $data, function($message) {
  45. $message->to('abc@xyz.in', 'Tutorials Point')->subject
  46. ('Laravel Basic Testing Mail');
  47. $message->from('abc.xyz@gmail.com','Virat Gandhi');
  48. });
  49. echo "Basic Email Sent. Check your inbox.";
  50. }
  51. }
  52.  
  53. Mail.blade.php
  54. <h1>Hi, {{ $name }}</h1>
  55. <p>Sending Mail from Laravel.</p>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement