darkrockmountain / gomail

GoMail is a powerful library for sending emails via multiple providers, including SMTP, Gmail API, Microsoft Graph API, SendGrid, AWS SES, Mailgun, Mandrill, Postmark, and SparkPost. Supporting attachments, plain text, and HTML content, it simplifies email integration for developers with easy setup and robust functionalities.
https://darkrockmountain.com
Apache License 2.0
4 stars 1 forks source link

[BUG] - Incorrect Attachment Encoding in Microsoft 365 Provider Results in Invalid Attachments #45

Closed DarkRockMountain-admin closed 15 hours ago

DarkRockMountain-admin commented 1 week ago

Describe the bug Attachments in emails sent using the Microsoft 365 provider in the GoMail library are improperly processed. They are being encoded into Base64 strings and then converted into byte arrays, which results in incorrect attachment data being sent.

To Reproduce Steps to reproduce the behavior:

  1. Set up the GoMail library with the Microsoft 365 provider.
  2. Create an email message with an attachment.
  3. Send the email.
  4. Check the received email and observe that the attachment is not processed correctly.

Expected behavior The attachment should be sent as raw byte data without being encoded into a Base64 string and then into a byte array. The email should contain the correct attachment file as expected.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context The issue is located in the composeMsMessage function within the microsoft365_email_sender.go file. The attachment handling code should be corrected to use attachment.GetRawContent() instead of encoding the attachment content to a Base64 string and then converting it to a byte array.