Skip to content

Commit 03e98a4

Browse files
committed
wip
1 parent daab6d2 commit 03e98a4

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

packages/mailer/src/Mailer.php

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public function send(string $path, ...$params): void
1616
{
1717
$html = $this->renderer->render(view($path, ...$params));
1818

19-
[$header, $body] = explode(PHP_EOL, $html, 2);
19+
[$headerString, $body] = explode(PHP_EOL, $html, 2);
2020

21-
$email = $this->makeEmail($header, $body);
21+
$email = $this->makeEmail($headerString, $body);
2222

2323
$this->sendEmail($email);
2424
}
@@ -32,26 +32,17 @@ public function sendEmail(Email $email): void
3232
ld($email);
3333
}
3434

35-
private function makeEmail(string $header, string $body): Email
35+
private function makeEmail(string $headerString, string $body): Email
3636
{
3737
$parsedHeaders = [];
3838

39-
$headers = explode(';', $header);
39+
preg_match_all('/(?<header>\w+)="(?<value>.*?)"/', $headerString, $headers);
4040

41-
foreach ($headers as $header) {
42-
if (trim($header) === '') {
43-
continue;
44-
}
41+
foreach ($headers[0] as $i => $line) {
42+
$header = $headers['header'][$i];
43+
$value = $headers['value'][$i];
4544

46-
[$name, $value] = explode(':', $header);
47-
48-
$value = trim($value);
49-
50-
if ($value === '') {
51-
$value = null;
52-
}
53-
54-
$parsedHeaders[trim($name)] = $value;
45+
$parsedHeaders[$header] = $value;
5546
}
5647

5748
$parsedHeaders['attachments'] = explode(',', $parsedHeaders['attachments'] ?? '');

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' }}; attachments: {{ implode(',', $attachments ?? []) }};
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>

0 commit comments

Comments
 (0)