Changed the SMTP test server base port and updated the corresponding environment variable name to `TEST_BASEPORT_SMTP`. This ensures consistency across the test setup and CI workflow configuration.
In the CI configuration file, the TEST_BASEPORT environment variable was added to various job scopes. This ensures consistency and allows the test base port to be set properly across different OS versions and Go versions.
Moved TestServerPortBase initialization to use an environment variable `TEST_BASEPORT` if provided. This adjustment helps in specifying custom base ports for running tests, ensuring better flexibility in different testing environments.
Structured the initialization of SendError on connection errors to improve code readability and maintainability. This change affects the error handling in both client_120.go and client_119.go by spreading the error details across multiple lines.
Added support for Enhanced Status Codes (ESC) when checking the SMTP client's extensions. The SendError struct now includes the error code and enhanced status code for improved diagnostics.
Previously, only the isTemp flag was considered when aggregating errors. Now, the error code and enhanced status code from the last error are also included. This ensures more comprehensive error reporting and handling.
Added a check for the ENHANCEDSTATUSCODES extension and included error code and enhanced status code information in SendError. This helps in providing more detailed error reporting and troubleshooting.
Renamed `getErrorCode` function to `errorCode` for consistency. Added new tests for the `enhancedStatusCode` function to validate its behavior with various error scenarios.
Renamed `getErrorCode` to `errorCode` and `getEnhancedStatusCode` to `enhancedStatusCode` for consistency. Updated all references in `client.go` and `senderror.go` accordingly, improving readability and maintaining uniformity across the codebase.
Introduce a suite of unit tests for the getErrorCode function to validate its behavior with various error types, including go-mail errors, permanent and temporary errors, wrapper errors, non-4xx/5xx errors, and non-3-digit codes.
Implemented new unit tests for SendError to validate the enhanced status code and error codes in various scenarios, including nil SendError cases, errors with no enhanced status code, and errors with both permanent and temporary error codes. This ensures the correctness of the error handling behavior across different conditions.
Implemented ErrorCode method to retrieve the error code from the server response in SendError. This method distinguishes between server-generated errors and client-generated errors, returning 0 for errors generated by the client.
Updated the TestServerPortBase from 12025 to 30025 to avoid port conflicts with other services running on the common 12025 port. This adjustment aims to ensure that the tests run reliably in diverse environments.
Enhance error handling by adding error code and enhanced status code to the SendError struct. This allows for better troubleshooting and debugging by providing more detailed SMTP server responses.
Revised the documentation for greater clarity: swapped the listed items for explicit and implicit SSL/TLS support, and detailed the supported SMTP authentication mechanisms in an itemized format. This ensures users understand all available options and configurations more clearly.
Updated SPDX identifiers from CC0-1.0 to MIT across multiple files, including `.github`, `CONTRIBUTING.md`, `README.md`, and more. Deleted the `LICENSES/CC0-1.0.txt` file as it is no longer relevant.
Corrected multiple instances of the misspelled "Content-Dispositon" to "Content-Disposition" in the msgwriter_test.go file. This ensures that the error messages in the tests are accurate and improve code readability.
Corrected multiple instances of the word "non-existant" to "non-existent" in test descriptions to improve code clarity and accuracy. This change affects both smtp_test.go and msg_test.go files.
The test name had a typo in the word "recipient." This commit corrects "recepient" to "recipient" to improve code readability and maintain consistency in naming conventions. This change does not modify any functional behavior of the tests.
Moved serverProps outside goroutines to improve code readability and maintainability. Added a RWMutex to serverProps to ensure thread-safe access to EchoBuffer, preventing race conditions during concurrent writes.
Renamed 'err' to 'berr' to avoid shadowing outer variable. This change ensures clearer error handling and avoids potential issues with variable scope and readability in the smtp_test.go file.
Removed JSON logger tests from smtp_test.go and relocated them to a new file smtp_121_test.go, ensuring compliance with Go 1.21. This change maintains test integrity while organizing tests by Go version compatibility.
Removed redundant mutex and streamlined anonymous goroutine syntax for test server setup by passing echoBuffer directly as a parameter. This change reduces unnecessary use of shared resources and simplifies the test code structure and fixes potential race conditions
Introduced a mutex to the SMTP test server properties to ensure thread-safe access when handling connections. This prevents race conditions and improves the reliability of the test server under concurrent load.
Changed variable declarations from '=' to ':=' to properly handle errors within the SMTP test cases. This ensures that errors are correctly captured and reported when writing to the EchoBuffer.
Removed unused variables and improved error handling in smtp_test.go. Adjusted to capture only error in auth.Next() calls, ensuring accurate validation. Added necessary error checks after creating new client connections to prevent test failures.
Introduce unit tests to verify the behavior of the debug logging in the Client. Confirm that logs are correctly produced when debug mode is enabled and appropriately suppressed when it is disabled.
This commit introduces four test cases for the GetTLSConnectionState method. These tests cover scenarios with a valid TLS connection, no connection, a non-TLS connection, and a non-TLS connection with the TLS flag set on the client. This ensures comprehensive validation of the method's behavior across different states.
Introduce new tests to verify behaviors of client methods including SetLogAuthData, SetDSNRcptNotifyOption, SetDSNMailReturnOption, HasConnection, and UpdateDeadline. Ensure these tests cover various scenarios such as successful operations, edge cases, and failure conditions.
Ensure that the connection is not nil before setting the deadline in the UpdateDeadline method. This prevents a potential runtime panic when attempting to set a deadline on a nil connection.
This commit introduces unit tests for the Client's SetLogger method. It verifies the correct logger type is set and ensures setting a nil logger does not override an existing logger.
Add mutex locking to ensure thread-safety when setting the logger in the `smtp` package. This prevents potential race conditions and ensures that the logger is updated consistently in concurrent operations.
These tests verify the behavior of the SetDebugLog method in various scenarios such as enabling and disabling debug logging and ensuring the logger type is as expected. This improves the robustness and reliability of the debug logging functionality in the Client class.
Deleted multiple outdated and redundant tests from the SMTP client test suite to streamline and improve the maintainability of the test codebase. This change focuses on removing tests that are no longer relevant or have been superseded by other methods.
Introduced new unit tests to verify the SMTP client's behavior with extensions, reset, and noop commands under various server conditions. Updated server response handling to correctly manage feature sets when they are empty.
This commit introduces multiple test cases to handle SMTP failure scenarios such as invalid host, newline in addresses, EHLO/HELO failures, and malformed data injections. Additionally, it includes improvements in error handling for these specific conditions.
Corrected indentation inconsistencies in the smtp_test.go file. Added multiple test cases to verify the failure scenarios for `SendMail` under various conditions including invalid hostnames, newlines in the address fields, and server failures during EHLO/HELO, STARTTLS, and authentication stages.
Refactored SMTP server tests to use an echo buffer for capturing responses. This allows for better validation of command responses without relying on error messages. Additionally, added a new test case to validate a full SendMail transaction with TLS and authentication.
The testHookStartTLS variable and its related conditional code have been removed from the smtp.go file. This cleanup streamlines the TLS initiation process and removes unnecessary test-specific hooks no longer in use.
Replace repetitive TLS configuration code with a reusable `getTLSConfig` helper function for consistency and maintainability. Additionally, update port configuration and add new tests for mail data transmission.