Sending Emails

Prerequisites

Add the Mail Facade to the Controller:

use Illuminate\Support\Facades\Mail;

Add the following to .env:

MAIL_DRIVER=mailgun
MAILGUN_DOMAIN="THE MAILGUN DOMAIN"
MAILGUN_SECRET="THE MAILGUN SECRET"
MAIL_FROM_NAME="OUR ORG NAME"

Templates

Sending a welcome email

$data = array(
  'company' => 'Some Company',
  'username' => 'bob@test.com',
  'password' => '1240982140j0noasdf231'
);

Mail::send('emails.adduser', $data, function($message) use ($subject, $to) {
  $message->subject($subject);
  $message->from('no-reply@tpv.com', 'TPV.com');
  $message->to($to);
});

Raw Email

Mail::raw('This is the text that goes into the email.', function ($message) use ($subject, $to) { $message->subject($subject); $message->from('no-reply@tpv.com', 'TPV.com'); $message->to($to); });