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

send multiple mail in laravel

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

laravel mail send to multiple recipients

$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);
	}
);
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 :: snippet doctrine orm with types 
Php :: woocommerce_default_catalog_orderby desc 
Php :: run php after product added 
Php :: evaluate home tilde ~ in php 
Php :: phphtml 
Php :: QR CODE FROM CAMCODES 
Php :: wp clean db terms 
Php :: PHP Example - AJAX Poll 
Php :: set session expire time in php 
Php :: how to create header in csv file inphp 
Php :: append data to json file php 
Php :: laravel tinker to test email on server 
Php :: laravel collection load 
Php :: php check if weekends 
Php :: laravel gigapay delete employee 
Php :: Eine Breadcrumb-Navigation ohne Plugin erstellen 
Php :: $user-id show 0 in blade laravel 8 
Php :: Never return type - PHP 8.1 
Php :: wp_signon wordpress login subdomain 
Php :: only fetch specific array keys php 
Php :: php pdo multiple insert 
Php :: Php countup from a date 
Php :: php refresh_ttl 
Php :: Call to undefined method :last() 
Php :: onde fica o php ini ubuntu 
Php :: redaxo urlgenerator 
Php :: show only fatal errors php 
Php :: Add custom column at custom posts list 
Php :: WordPress Creating “startupl” folder and Wrtting to .htaccess 
Php :: seeder name singular or plural laravel 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =