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 - Send mail using mail class

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

                });

            }
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 :: php sort by key 
Php :: disadvantages of php 
Php :: defining route through controller 
Php :: return ob_start 
Php :: How to install or setup sanctum for laravel api authentication 
Php :: unique check two clolumn in laravel validation 
Php :: if statement php 
Php :: laravel phpunit not run test 
Php :: php artisan serve stop 
Php :: laravel validate change password 
Php :: laravel one command for model table and controller 
Php :: strtotime php 
Php :: -sale_price 
Php :: laravel migration bigint length 
Php :: @method overide form laravel 
Php :: vindecoder.eu php 
Php :: magento 2 select to string 
Php :: swagger laravel 
Php :: wc php product_cat thumbnail 
Php :: php extend class 
Php :: post is empty php api 
Php :: laravel digits between does not working 
Php :: php simple sse 
Php :: octobercms mail register 
Php :: how to fetch days old records php mysql 
Php :: laravel hide columns 
Php :: Laravel htaccess for aws ec2 
Php :: php $_server 
Php :: simple bindings laravel 
Php :: woocommerce order get product weight 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =