Skip to content

Commit 211f9a7

Browse files
committed
Issue-85: Fixed attachment not working issue
Signed-off-by: sergiu <sergiubota@rospace.com>
1 parent 442f61a commit 211f9a7

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/Service/LogService.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Dot\Mail\Service;
66

7+
use DateTimeImmutable;
78
use Dot\Mail\Email;
89

910
use function date;
@@ -56,7 +57,9 @@ public function sent(Email $message): false|int|null
5657
'cc' => $this->extractAddresses($message->getCc()),
5758
'bcc' => $this->extractAddresses($message->getBcc()),
5859
];
59-
$data = sprintf('[%s]: %s' . PHP_EOL, date('Y-m-d H:i:s'), json_encode($data));
60+
61+
$date = new DateTimeImmutable();
62+
$data = sprintf('[%s]: %s' . PHP_EOL, $date->format('Y-m-d H:i:s'), json_encode($data));
6063

6164
/**
6265
* Write the log data and return the result

src/Service/MailService.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public function send(): ResultInterface
6161
//attach files before sending
6262
$this->attachFiles();
6363
$this->getTransport()->send($this->getMessage());
64+
$this->getMessage()->setBody(null);
6465

6566
$this->getEventManager()->triggerEvent($this->createMailEvent(MailEvent::EVENT_MAIL_POST_SEND, $result));
6667
} catch (Exception $e) {
@@ -102,7 +103,7 @@ public function attachFiles(): false|Email
102103
continue;
103104
}
104105
$basename = is_string($key) ? $key : basename($attachment);
105-
$attachedFile = new DataPart($attachment, $basename, null);
106+
$attachedFile = new DataPart(fopen($attachment, 'r'), $basename);
106107
$mimeMessage = new MixedPart($mimeMessage, $attachedFile);
107108

108109
$this->message->setBody($mimeMessage);

0 commit comments

Comments
 (0)