Skip to content

Commit d622484

Browse files
committed
Add attachments
1 parent 275b608 commit d622484

File tree

5 files changed

+13
-2
lines changed

5 files changed

+13
-2
lines changed

packages/mailer/src/Mailer.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,17 @@ private function makeEmail(string $header, string $body): Email
3939
$headers = explode(';', $header);
4040

4141
foreach ($headers as $header) {
42+
if (trim($header) === '') {
43+
continue;
44+
}
45+
4246
[$name, $value] = explode(':', $header);
4347

4448
$parsedHeaders[trim($name)] = trim($value);
4549
}
4650

51+
$parsedHeaders['attachments'] = explode(',', $parsedHeaders['attachments'] ?? '');
52+
4753
$data = [
4854
...$parsedHeaders,
4955
'body' => $body,

packages/mailer/src/x-mail.view.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from: {{ $from }}; to: {{ $to }}; subject: {{ $subject }}; async: {{ ($async ?? true) ? 'true' : 'false' }}
1+
from: {{ $from }}; to: {{ $to }}; subject: {{ $subject }}; async: {{ ($async ?? true) ? 'true' : 'false' }}; attachments: {{ implode(',', $attachments ?? []) }};
22
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
33
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
44
<head>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hi

tests/Integration/Mailer/MailerTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ public function test_mailer(): void
1717
1818
subject: 'Hello there',
1919
name: 'Brent',
20+
files: [
21+
__DIR__ . '/Fixtures/attachment.txt',
22+
__DIR__ . '/test-mail.view.php',
23+
]
2024
);
2125
}
2226
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<x-mail :to="$to" subject="$subject">
1+
<x-mail :to="$to" :subject="$subject" :attachments="$files">
22
Hello {{ $name }}
33
</x-mail>

0 commit comments

Comments
 (0)