Skip to content

Instantly share code, notes, and snippets.

@alexkingorg
Last active August 18, 2016 13:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexkingorg/d2923deeea1b0076d07a to your computer and use it in GitHub Desktop.
Save alexkingorg/d2923deeea1b0076d07a to your computer and use it in GitHub Desktop.
Sane Laravel Mail example code
<?php
// note, to use $subject within your closure below you have to pass it along in the "use (...)" clause.
$subject = 'Welcome!';
Mail::send('emails.welcome', ['key' => 'value'], function($message) use ($subject) {
// note: if you don't set this, it will use the defaults from config/mail.php
$message->from('bar@example.com', 'Sender Name');
$message->to('foo@example.com', 'John Smith')
->subject($subject);
});
@byeblogs
Copy link

Hey man, i still dont get it what is a 'emails.welcome' and ['key' => 'value'] ?! would be nice if you want tell me about it :)

@shahidkarimi
Copy link

shahidkarimi commented Aug 18, 2016

I dont want the template. How to send simple email to any email address?
Mail::send("test@test.com","hi","Hello body")

@shahidkarimi
Copy link

Sending simple email is just a headache in Laravel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment