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.
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:
Unmarshal an EmailMessage JSON object without specifying the maxAttachmentSize field.
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):
OS: Linux
Go version: 1.22.4
gomail version: v0.6.0-beta.3
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.
Describe the bug When unmarshalling an
EmailMessage
, themaxAttachmentSize
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:
EmailMessage
JSON object without specifying themaxAttachmentSize
field.maxAttachmentSize
is set to 0.Expected behavior The
maxAttachmentSize
should be set toDefaultMaxAttachmentSize
when theEmailMessage
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. SettingmaxAttachmentSize
toDefaultMaxAttachmentSize
during unmarshalling will ensure attachments are processed correctly according to the intended size limits.Proposed Solution Modify the
UnmarshalJSON
method for theEmailMessage
struct to setmaxAttachmentSize
toDefaultMaxAttachmentSize
if it is not specified in the JSON input.