Skip to content

Instantly share code, notes, and snippets.

@alexkingorg
Last active August 18, 2016 13:55
Show Gist options
  • 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('[email protected]', 'Sender Name');
$message->to('[email protected]', '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("[email protected]","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