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.
Is your feature request related to a problem? Please describe.
Currently, the SendEmail method in the EmailSender interface accepts an EmailMessage struct by value. This approach can be inefficient as it involves copying the entire EmailMessage struct, which can be costly in terms of performance, especially when handling large messages or attachments.
Describe the solution you'd like
The proposed solution is to modify the SendEmail method in the EmailSender interface to accept a pointer to EmailMessage instead of the struct by value. This change will enhance performance by avoiding unnecessary copying of the struct. The updated interface definition would be:
type EmailSender interface {
// SendEmail sends an email with the given message.
// Parameters:
// - message: A pointer to an EmailMessage struct containing the details of the email to be sent.
// Returns:
// - error: An error if sending the email fails, otherwise nil.
SendEmail(message *EmailMessage) error
}
Describe alternatives you've considered
An alternative approach would involve keeping the current method signature and optimizing other parts of the code. However, this would not address the fundamental inefficiency of copying the EmailMessage struct. Passing a pointer is a more straightforward and effective solution.
Additional context
This feature will improve the performance of the gomail package by reducing the overhead associated with copying large structs. It aligns with Go best practices for handling large data structures and ensures more efficient memory usage. The implementation will include updates to existing tests and documentation to reflect this change.
Is your feature request related to a problem? Please describe. Currently, the
SendEmail
method in theEmailSender
interface accepts anEmailMessage
struct by value. This approach can be inefficient as it involves copying the entireEmailMessage
struct, which can be costly in terms of performance, especially when handling large messages or attachments.Describe the solution you'd like The proposed solution is to modify the
SendEmail
method in theEmailSender
interface to accept a pointer toEmailMessage
instead of the struct by value. This change will enhance performance by avoiding unnecessary copying of the struct. The updated interface definition would be:Describe alternatives you've considered An alternative approach would involve keeping the current method signature and optimizing other parts of the code. However, this would not address the fundamental inefficiency of copying the
EmailMessage
struct. Passing a pointer is a more straightforward and effective solution.Additional context This feature will improve the performance of the
gomail
package by reducing the overhead associated with copying large structs. It aligns with Go best practices for handling large data structures and ensures more efficient memory usage. The implementation will include updates to existing tests and documentation to reflect this change.