Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel mail send

$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

laravel mail cc

Mail::to($email)
    ->cc(['name1@domain.com','name2@domain.com'])
    ->send(new document());
Comment

laravel mailable from

return (new Mail)
    ->to('hello@example.com')
    ->from('hello@example.com');
Comment

mail laravel

/**
 * Build the message.
 *
 * @return $this
 */
public function build()
{
    return $this->from('example@example.com')
                ->markdown('emails.orders.shipped', [
                    'url' => $this->orderUrl,
                ]);
}
Comment

laravel mail

@verbatim
    <div class="container">
        Hello, {{ name }}.
    </div>
@endverbatim
Comment

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 :: fillable vs guarded laravel 
Php :: php warning: php startup: unable to load dynamic library 
Php :: Write a php program to print hello world 
Php :: twig resto 
Php :: laravel reading log file 
Php :: signup api in laravel 
Php :: php library to convert html to amp 
Php :: join string php 
Php :: convert collection to array laravel 
Php :: drop foreign key laravel eloquent 
Php :: laravel collection combine 
Php :: How do i multiple variables in php 
Php :: laravel get namespace 
Php :: How to use Query builder with eloquent in Laravel 8? 
Php :: php file storage 
Php :: api resource create in laravel 
Php :: removing the last value of an array 
Php :: download npm package 
Php :: Laravel return empty relationship on model when condition is true 
Php :: call jquery function in php code 
Php :: add character after x characters in php 
Php :: how to install phpmyadmin on windows 10 
Php :: mktime() php 
Php :: php rce command 
Php :: Eager realationship in laravel 
Php :: laravel migrate error default character 199 boot 
Php :: laravel collection contains 
Php :: laravel custom validation 
Php :: php create empty array with size 
Php :: laravel firstorcreate usage 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =