Updated the Reader struct in reader.go to properly handle nil buffers. This prevents potential errors from nil pointer dereference. Also added the fmt package for debugging purposes. Correspondingly, additional tests in reader_test.go were also added to cover these edge cases and ensure the Reader struct correctly handles them.
Extended null check conditions in msgwriter.go to prevent potential nil pointer dereference. This change ensures robustness in error handling in scenarios where FROM header or envelope FROM is either not existent or nil.
Added an additional condition in the SendErrorIsTemp function within msg.go to ensure that the error e is not nil before referencing it. This guards against potential runtime panics from dereferencing a nil pointer, enhancing robustness of error handling.
Introduced a new condition that checks and returns an error if either STDERR or STDIN pipe is nil in the msg function of msg.go. This improves error handling by preventing potential panic due to referencing a nil pipe.
Converted the range loop in the GetAddrHeaderString function in msg.go to use value semantics rather than index notation. This improves code clarity by not unnecessarily referring to m.addrHeader[h] in the loop and instead referencing the value directly (using variable mh), making it easier to understand and maintain.
A change was made in the SMTP client creation process to add more robust error handling. The new logic checks if the client is null after being created and, if true, returns an error. This update can help prevent potential null pointer exceptions in runtime, ultimately leading to more stable application.
Added a nil check in the IsTemp method in senderror.go to prevent runtime errors when method is called on a nil object. The method now immediately returns false if it is invoked on a nil *SendError, ensuring the program's robustness against potential misuse. This increases the robustness and readability of the
Added a condition to prevent assignment of an empty address list to the 'HeaderFrom' scenario. This eliminates potential runtime errors when trying to access an nonexistent element of a slice.
Adjusted error handling in the sendmail execution part by reusing the 'err' variable, promoting cleaner, more readable code.
Tests for new mail address handling methods have been updated to use {Name:"", Address: "email@example.com"} format for initializing the []*mail.Address slices, instead of the previous shorthand {"", "email@example.com"}. This was done to increase code clarity and explicitness.
This commit introduces a new type 'JSONlog' that satisfies the Logger interface for structured JSON logging. This includes new methods 'Debugf', 'Infof', 'Warnf' and 'Errorf' to log messages at different levels and an associated test 'jsonlog_test.go' to ensure correct functionality. This enhances the logging functionality by providing clarity in logs and eases debugging process.
Moved Level constants and directionPrefix() function from log/stdlog.go to log/log.go. This change improves the organization of the code by grouping log level constants and related functions in the same file. Furthermore, this removes redundancy and ensures consistency of log level across different files.
The deleted .idea XML configuration files (markdown.xml, modules.xml, Project_Default.xml) were not required for the functioning of the project. Removing these files helps in reducing clutter and simplifying the project structure. Also, these files can often contain user-specific settings or paths, and may cause conflicts when working in a team.
This commit updates the Go version from 1.20 to 1.21 on three GitHub workflow files: golangci-lint.yml, codecov.yml, and sonarqube.yml. The change ensures we use the latest Go version which is more efficient and comes with additional features, leading to improved project performance.
The .idea/vcs.xml file was deleted because it is not needed for the project. It was initially created by the IntelliJ IDEA but we're managing version control configurations through another way, making this file redundant.
Deleted the `.idea/go-mail.iml` file which was committed in error and should not be part of the source code repository. Updated the `.gitignore` file to ignore the whole `.idea` directory, since it contains configuration files that are specific to each developers environment and not required for the project build. The changes in the repository will now make it more clutter-free and prevent unintentional commits of unnecessary files in the future.
In the updated version of msgwriter.go, an additional error handling process has been included. If an error is detected when creating a new part in the message writer, this error is stored and prevents executing the writeBody function. This fixes nil pointer dereference in `mw.writeBody` if an error occured previously.
In the updated version of msgwriter.go, an additional error handling process has been included. If an error is detected when creating a new part in the message writer, this error is stored and prevents executing the writeBody function. This fixes nil pointer dereference in `mw.writeBody` if an error occured previously
The logging system in the smtp.go and log package has been refactored. A new custom log type `Log` was introduced, that includes the message direction, format and arguments. The `Logger` interface and the `Stdlog` implementation were modified to accept this new type. This change provides a clearer understanding of message direction inside logs, allowing for easier debugging and reduced complexity. This change does not affect features or disrupt user functionality. Additionally, it allows for custom implementations of the log.Logger interface to without being forced to use the C --> S/C <-- S direction logging.
A `const CallDepth` placeholder has been introduced and has been set to 2. This is used as an argument in Output method calls in various log levels like debug, info, warn, and error in place of previously hardcoded '2'. This change improves the readability of the code. The '2' represented the call depth of log.Logger's Output method, which wasn't immediately clear with the hardcoded value.
- Bump version in doc.go
- Add sonarlint to .gitignore
- Update README to reflect the changes and contributors
- Fixed typos in auth_cram_md5_118.go, msg.go, msg_test.go, reader.go and smtp_ehlo_117.go
Fixes#121. `defer` in for loops can possibly lead to leaks.
The whole handling including the defer are now moved into anonymous functions outside the for loop and are called form the loop instead. This way the defer is handle when the inline function finishes