Skip to content

Commit a1bc25d

Browse files
authored
Update MailService.php
Set mail body to null to discard previous attachments Signed-off-by: APaikens <shamanis@gmail.com>
1 parent 7fd8c21 commit a1bc25d

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/Service/MailService.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ public function send(): ResultInterface
7070
//trigger error event
7171
$this->getEventManager()->triggerEvent($this->createMailEvent(MailEvent::EVENT_MAIL_SEND_ERROR, $result));
7272
throw new MailException($result->getMessage());
73+
} finally {
74+
// Reset the Symfony Message body after every send attempt (success or failure).
75+
// attachFiles() embeds DataParts into Message::$body; without this reset those
76+
// DataParts survive a failed send and get wrapped into the next email's body,
77+
// causing attachments from a failed send to leak into subsequent emails.
78+
$this->getMessage()->setBody(null);
7379
}
7480

7581
if ($result->isValid()) {

0 commit comments

Comments
 (0)