// $data => array of information passed to view
Mail::send('email_view', $data, function ($m) use ($user) {
$m->from("example@gmail.com", config('app.name', 'APP Name'));
$m->to($user->email, $user->name)->subject('Email Subject!');
});
$arrayEmails = ['someone@mail.com','stranger@mail.com'];
$emailSubject = 'My Subject';
$emailBody = 'Hello, this is my message content.';
Mail::send('emails.normal',
['msg' => $emailBody],
function($message) use ($arrayEmails, $emailSubject) {
$message->to($arrayEmails)
->subject($emailSubject);
}
);
public function index()
{
$data = array('name'=>"vikash Mirdha");
Mail::send('mailview',$data,function($message) {
$message->to('jobs9493@gmail.com');
$message->subject('Welcome Mail');
});
dd('Mail Send Successfully');
Mail::send(['html' => 'admin.email-template.lowstock'], array('totalUsers' => $totalUsers, 'item' => $item,'data' =>$data), function ($message) use ($user_to_mail, $item) {
$message->from('POS@gmail.com', 'POS');
$message->subject('Notification Mail');
foreach ($user_to_mail as $mail) {
$message->to($mail->email);
}
});
}
return (new Mail)
->to('hello@example.com')
->from('hello@example.com');
Mail::raw('Text to e-mail', function ($message) {
//
});
@verbatim
<div class="container">
Hello, {{ name }}.
</div>
@endverbatim
<?php
namespace AppMail;
use AppModelsOrder;
use IlluminateBusQueueable;
use IlluminateMailMailable;
use IlluminateQueueSerializesModels;
class OrderShipped extends Mailable
{
use Queueable, SerializesModels;
/**
* The order instance.
*
* @var AppModelsOrder
*/
protected $order;
/**
* Create a new message instance.
*
* @param AppModelsOrder $order
* @return void
*/
public function __construct(Order $order)
{
$this->order = $order;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
// if only 1 file
return $this->view('emails.orders.shipped')->attach($this->order['invoice']);
// if multiple files then i use this code
return $this->view('emails.orders.shipped');
foreach ($this->order['invoice'] as $file){
$this->attach($file);
}
}
}
// Please do comment if you have a better approach
// We all here to find shorter and faster way to get things done
// Thank you