send mail with attachment in the controller laravel 8

Solutions on MaxInterview for send mail with attachment in the controller laravel 8 by the best coders in the world

showing results for - "send mail with attachment in the controller laravel 8"
Yahir
07 Apr 2017
1Reference link
2https://thecodelearners.com/laravel-sending-emails-with-multiple-attachments/
3
4
5# add 
6Use Mail;
7use App\Mail\PurchaseInvoiceInformation;
8
9public function sendEmailWithMultipleAttachments(Request $request){
10    $data = [
11        "to" => "pavanbaddi911@gmail.com",
12        "attachments" => [
13            [
14                "path" => public_path('uploads/inv-005.pdf'),
15                "as" => "Purchase Invoice NO 005.pdf",
16                "mime" => "application/pdf",
17            ],
18            [
19                "path" => public_path('uploads/inv-007.pdf'),
20                "as" => "Purchase Invoice NO 007.pdf",
21                "mime" => "application/pdf",
22            ],
23            [
24                "path" => public_path('uploads/inv-009.pdf'),
25                "as" => "Purchase Invoice NO 009.pdf",
26                "mime" => "application/pdf",
27            ],
28        ],
29    ];
30    return Mail::to($data['to'])->send(new PurchaseInvoiceInformation($data));
31}
32# App\Mail\PurchaseInvoiceInformation;
33
34<?php
35
36namespace App\Mail;
37
38use Illuminate\Bus\Queueable;
39use Illuminate\Contracts\Queue\ShouldQueue;
40use Illuminate\Mail\Mailable;
41use Illuminate\Queue\SerializesModels;
42
43class PurchaseInvoiceInformation extends Mailable
44{
45    use Queueable, SerializesModels;
46
47    /**
48        * Create a new message instance.
49        *
50        * @return void
51        */
52
53    protected $data;
54
55    public function __construct($data)
56    {
57        $this->data = $data;
58    }
59
60    /**
61        * Build the message.
62        *
63        * @return $this
64        */
65    public function build()
66    {
67        $mail = $this->from('to-email@example.com')
68                    ->view('emails.purchase-invoice-information');
69
70        if(!empty($this->data["attachments"])){
71            foreach($this->data["attachments"] as $k => $v){
72                $mail = $mail->attach($v["path"], [
73                    'as' => $v["as"],
74                    'mime' => $v["mime"],
75                ]);
76            }
77        }
78                
79    }
80}    
81 # blade file 
82
83<!DOCTYPE html>
84<html lang="en">
85<head>
86    <meta charset="UTF-8">
87    <meta name="viewport" content="width=device-width, initial-scale=1.0">
88    <title>Purchase Invoice</title>
89</head>
90<body>
91    <h1>Invoice Information</h1>
92
93    <p>Dear User,</p>
94    <p>Find invoices for your purchase order INV005, INV007, INV009.</p>
95
96</body>
97</html>
queries leading to this page
attachment in laravel mailmail laravel attachmentlaravel mail attachment from storagehow to send mail form controller laravel 8laravel 8 mail send attachment for beginnerslaravel 8 mail send attachmentattachments laravel maillaravel 8 send mail with attachmentlaravel send attachment in email smtpsend email attachment in contact laravelmail send laravel 8laravel attachment maillaravel mailjet attachmentlaravel 8 mail send examplemail attachment in larvelget attachment value from database and send mail using laravellaravel mail attachmentssend email with attachment laravel sending mail with attachments to users in laravelhow to send email with attachment in laravelsend mail using laravel 8laravel mail attachmentlaravel send email with attachmentsend blade attachment in mail laravelsend mail in laravel with attachmenthow to laravel invoice send as mail attachmentsending attachments laravel mailsend email with attachment in laravellaravel mailable attachmentsend email laravel 8 with attachmenthow to send email with single attachment via mailable in laravel 8display mail sending contents in laravel laravel send email with attachmentslaravel send email with attachment examplesend email wth attachment laravellaravel send mail attachmentlaravel send mail with attachmentmail send with attachment in laravelattachment method in laravel mailablemail send with attachment from form in laravellaravel make mail with blade filehow to add attachment to email in laravellaravel mail send attachments to buildsend text mail in laravel 8mail with attachment in laravelemail attachment in laravelhow to send mail with data in laravel 8mail attachements laravel 8laravel set mail attachment namesend attachment with mail in laravelsend attachment in email laravelhow to send attachment in mail laravelmail attachment in laravelhow to send mailusing laravel 8send attachment mail laravelsend mail with attachment laravellaravel mail 3a 3asend attachmentemail with attachment laravellaravel 8 send email with attachmenthow to send attachment in mail using laravelsend attachment in mail with php laravelsend email with attachment on form submission using laravel 8can i pass an attachment in mail manager laravellaravel send mail html contentsmail send in laravel 8send mail in laravel 7 with attachment examplelaravel send mail eith attachment file typehow to send a file via mailable in laravellaravel send email with attachment html stringhow to send mail with attachment file laravellaravel email with attachmentlaravel 8 send mail examplelaravel mail attachment namesend email using laravel 7 with attachmentsend attachment link in mail laravelhow to send email with attachment in laravel 8laravel send attachments with emaillaravel mail send variables from controllerlaravel 7 mail attachmenthow to send a file via mailable in laravel 8laravel 5 send mail with attachmentuse laravel in sending email attachmentslaravel mail attachment from databaselaravel mail send attachmentsend attachment in mail laravellaravel mail form file as attachmentlaravel send email with attachment 8mail pass parameters in laravelhow to send email attachment in laravellaravel send mail attachment using mail classlaravel send mail with attachment file typeread an attachment from email in laravelsend attachment in mail using laravelsend mail in laravel 8 with attachmentattachment in laravel 8 mailhow to attachment in mail in laravelmail with attachment laravelattach file to mail in controller laravellaravel mail send with attachment show 1kblaravel 7 send email with attachmentlaravel mail with attachmentsend mail with laravel 8attachment method in laravel maillaravel send mail with filelaravel 8 send add attachment to emailsend email with attachment in laravel 8laravel 8 queues send emaillaravel send email with attachment from request send mail with attachment in laravelmail attachment laravellaravel send mail with attachment from custom pathlaravel mail send filessend attachment in mail function in laravellaravel email send attachmentlaravel 7 send mail with attachmentlaravel send attachment emailsend an email from laravel with attachment examplelaravel send email with attachment requestget attachments from laravel mailhow to send mail with attachment in laravellaravel 5 8 send email with attachmentattachment mailjet for laravellaravel mail 3a 3ato attachmentlaravel mail send with attachmentsend mail with attachment in the controller laravel 8laravel mail 3a 3asend attach filesend variable from controller to mail laravel for attachmentsend mail with attachments using php mail direct laravelsend mail in laravel document in attachmentattachment through laravel mailablelaravel send email attachmentlaravel send attachment to email from requesthow to send mails with attachments in laravelsend mail with attachments using laravelsend mail laravel with attachmentlaravel 5 send mail attachmentlaravel mail with attachmentshow to send mails with attachments in laravel 8laravel mail add attachmentsend mail with attachment in the controller laravel 8