diff --git a/src/Appwrite/Event/Mail.php b/src/Appwrite/Event/Mail.php index 95fffa90d8..47c9125c01 100644 --- a/src/Appwrite/Event/Mail.php +++ b/src/Appwrite/Event/Mail.php @@ -317,11 +317,12 @@ class Mail extends Event public function setAttachment(string $content, string $filename, string $encoding = 'base64', string $type = 'plain/text') { $this->attachment = [ - 'content' => $content, + 'content' => base64_encode($content), 'filename' => $filename, 'encoding' => $encoding, 'type' => $type, ]; + return $this; } public function getAttachment(): array diff --git a/src/Appwrite/Platform/Workers/Mails.php b/src/Appwrite/Platform/Workers/Mails.php index bb55133c0b..9018f219ae 100644 --- a/src/Appwrite/Platform/Workers/Mails.php +++ b/src/Appwrite/Platform/Workers/Mails.php @@ -92,7 +92,7 @@ class Mails extends Action $mail->AltBody = \strip_tags($body); if (!empty($attachment['content'] ?? '')) { $mail->AddStringAttachment( - $attachment['content'], + base64_decode($attachment['content']), $attachment['filename'] ?? 'unknown.file', $attachment['encoding'] ?? PHPMailer::ENCODING_BASE64, $attachment['type'] ?? 'plain/text'