Search
 
SCRIPT & CODE EXAMPLE
 

PHP

attach multiple files in laravel mailable

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;
}
Comment

attach one or multiple files laravel mail

<?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
Comment

PREVIOUS NEXT
Code Example
Php :: get the current page id in wordpress 
Php :: laravel getbindings 
Php :: hash a password php 
Php :: laravel where creation is today carbon 
Php :: laravel db does not exists 
Php :: how to connect to a database in php 
Php :: php get all txt files in directory 
Php :: if is cart page woocommerce 
Php :: laravel env production 
Php :: composer remove cache 
Php :: wordpress disable errors 
Php :: laravel delete confirm link 
Php :: convert date to reverse date in php 
Php :: php create temporary file 
Php :: full name validation laravel 
Php :: how to split url in php 
Php :: return error when duplicated laravel 
Php :: send variable to get_template_part 
Php :: wordpress query orderby name 
Php :: set font sytle phpspreadsheet 
Php :: carbon set locale laravel 
Php :: get file each line in php 
Php :: laravel redirect back 
Php :: repeater acf 
Php :: php right characters 
Php :: groupby in laravel with count 
Php :: PHP auto refresh page 
Php :: validate timestamp php 
Php :: laravel faker car plate br mercossul 
Php :: transaction cakephp 2 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =