public function build()
{
$email = $this->view('emails.employment_mailview')->subject('Employment Application');
// $attachments is an array with file paths of attachments
foreach($attachments as $filePath){
$email->attach($filePath);
}
return $email;
}
$emails = ['myoneemail@esomething.com', 'myother@esomething.com','myother2@esomething.com'];
Mail::send('emails.welcome', [], function($message) use ($emails)
{
$message->to($emails)->subject('This is test e-mail');
});
var_dump( Mail:: failures());
exit;
$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);
}
);
<?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