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] - maxAttachmentSize set to 0 when Unmarshalling EmailMessage #39

Closed JRocabruna closed 13 hours ago

JRocabruna commented 3 weeks ago

Describe the bug When unmarshalling an EmailMessage, the maxAttachmentSize field is set to 0. This causes all attachments to be rejected because any attachment size will exceed the 0 threshold.

To Reproduce Steps to reproduce the behavior:

  1. Unmarshal an EmailMessage JSON object without specifying the maxAttachmentSize field.
  2. Observe that maxAttachmentSize is set to 0.

Expected behavior The maxAttachmentSize should be set to DefaultMaxAttachmentSize when the EmailMessage is unmarshalled, ensuring that attachments are handled correctly based on the default size limit.

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

Environment (please complete the following information):

Additional context This bug prevents any attachments from being accepted due to the maxAttachmentSize being set to 0 by default. Setting maxAttachmentSize to DefaultMaxAttachmentSize during unmarshalling will ensure attachments are processed correctly according to the intended size limits.

Proposed Solution Modify the UnmarshalJSON method for the EmailMessage struct to set maxAttachmentSize to DefaultMaxAttachmentSize if it is not specified in the JSON input.