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

[FEATURE] - Refactor EmailMessage Struct to Use Private Fields and Constructor for Enhanced Encapsulation and Data Integrity #5

Closed JRocabruna closed 13 hours ago

JRocabruna commented 1 month ago

Is your feature request related to a problem? Please describe. Currently, the EmailMessage struct has public fields, which allows external code to modify its state directly. This can lead to issues such as invalid data being set, inconsistent state, and potential security vulnerabilities. For example, email addresses might not be validated, and text inputs might not be sanitized, leading to injection attacks.

Describe the solution you'd like Refactor the EmailMessage struct to use private fields and provide a constructor and setter methods for field initialization and modification. This will ensure that:

Describe alternatives you've considered An alternative solution could be to keep the fields public and enforce validation externally, but this approach is error-prone and less secure compared to encapsulating the fields within the struct itself.

Additional context Encapsulation is a fundamental principle of object-oriented design that helps protect the integrity of an object’s data, hide implementation details, and provide a clear and controlled API. By refactoring the EmailMessage struct to use private fields and a constructor, we can enhance the robustness, security, and maintainability of the code.

github-actions[bot] commented 1 week ago

This issue is stale because it has been open for 30 days with no activity.