Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Service/LogService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Dot\Mail\Service;

use DateTimeImmutable;
use Dot\Mail\Email;

use function date;
use function dirname;
use function file_exists;
use function file_put_contents;
Expand Down Expand Up @@ -56,7 +56,9 @@ public function sent(Email $message): false|int|null
'cc' => $this->extractAddresses($message->getCc()),
'bcc' => $this->extractAddresses($message->getBcc()),
];
$data = sprintf('[%s]: %s' . PHP_EOL, date('Y-m-d H:i:s'), json_encode($data));

$date = new DateTimeImmutable();
$data = sprintf('[%s]: %s' . PHP_EOL, $date->format('Y-m-d H:i:s'), json_encode($data));

/**
* Write the log data and return the result
Expand Down
4 changes: 3 additions & 1 deletion src/Service/MailService.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use function array_merge;
use function basename;
use function count;
use function fopen;
use function is_file;
use function is_string;

Expand Down Expand Up @@ -61,6 +62,7 @@ public function send(): ResultInterface
//attach files before sending
$this->attachFiles();
$this->getTransport()->send($this->getMessage());
$this->getMessage()->setBody(null);

$this->getEventManager()->triggerEvent($this->createMailEvent(MailEvent::EVENT_MAIL_POST_SEND, $result));
} catch (Exception $e) {
Expand Down Expand Up @@ -102,7 +104,7 @@ public function attachFiles(): false|Email
continue;
}
$basename = is_string($key) ? $key : basename($attachment);
$attachedFile = new DataPart($attachment, $basename, null);
$attachedFile = new DataPart(fopen($attachment, 'r'), $basename);
$mimeMessage = new MixedPart($mimeMessage, $attachedFile);

$this->message->setBody($mimeMessage);
Expand Down