Commit graph

1363 commits

Author SHA1 Message Date
be4201b05a
Refactor debug logging and logger settings in Client
Separated debug logging and logger setting methods to include SMTP client parameter for better encapsulation. Removed commented-out code for cleaner and more manageable codebase.
2024-11-22 15:29:22 +01:00
55884786be
Refactor SMTP client functions to improve modularity
Refactor `DialWithContext` to delegate client creation to `SMTPClientFromDialWithContext`. Add new methods `SendWithSMTPClient`, `CloseWithSMTPClient`, and `ResetWithSMTPClient` to handle specific actions on `smtp.Client`. Simplify `auth`, `sendSingleMsg`, and `tls` methods by passing client as parameters.
2024-11-22 14:59:19 +01:00
f9e869061e
Add mutex locks to DSN option setters
Mutex locks are added to ensure thread safety when setting DSN mail return and recipient notify options. This prevents data races in concurrent environments, improving the client's robustness.
2024-11-22 14:58:41 +01:00
45776c052f
Refactor client error handling and add concurrent send tests
Updated tests to correctly assert the absence of an SMTP client on failure. Added concurrent sending tests for DialAndSendWithContext to improve test coverage and reliability. Also, refined the `AutoDiscover` and other client methods to ensure proper parameter use.
2024-11-22 14:58:05 +01:00
bc5d98031b
Merge pull request #384 from wneessen/dependabot/github_actions/github/codeql-action-3.27.5
Bump github/codeql-action from 3.27.4 to 3.27.5
2024-11-21 15:07:48 +01:00
c217f032bc
Merge pull request #383 from wneessen/dependabot/github_actions/codecov/codecov-action-5.0.7
Bump codecov/codecov-action from 5.0.4 to 5.0.7
2024-11-21 15:03:17 +01:00
d6c96dcd3d
Merge pull request #382 from wneessen/dependabot/github_actions/actions/dependency-review-action-4.5.0
Bump actions/dependency-review-action from 4.4.0 to 4.5.0
2024-11-21 15:03:03 +01:00
dependabot[bot]
62b3314c20
Bump github/codeql-action from 3.27.4 to 3.27.5
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.27.4 to 3.27.5.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](ea9e4e3799...f09c1c0a94)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-21 14:02:21 +00:00
dependabot[bot]
49606f197b
Bump codecov/codecov-action from 5.0.4 to 5.0.7
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.0.4 to 5.0.7.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](985343d705...015f24e681)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-21 14:02:09 +00:00
dependabot[bot]
e17965a891
Bump actions/dependency-review-action from 4.4.0 to 4.5.0
Bumps [actions/dependency-review-action](https://github.com/actions/dependency-review-action) from 4.4.0 to 4.5.0.
- [Release notes](https://github.com/actions/dependency-review-action/releases)
- [Commits](4081bf99e2...3b139cfc5f)

---
updated-dependencies:
- dependency-name: actions/dependency-review-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-21 14:02:01 +00:00
d00969886a
Merge pull request #381 from wneessen/bug/380_use-of-closed-network-connection-error-when-using-concurrently
Add mutex for concurrent send protection
2024-11-21 10:38:09 +01:00
6e9df0b724
Increase timeout for DialAndSend context
Updated the timeout for the DialAndSend context in 'client_test.go' from 5 seconds to 1 minute to ensure sufficient time for the operation to complete. This change helps prevent premature timeouts that can cause test failures.
2024-11-21 10:33:24 +01:00
1a579c2149
Add mutex for concurrent send protection
Introduced a sendMutex to synchronize access to shared resources in the DialAndSendWithContext method. This ensures thread safety when sending multiple messages concurrently. Added a corresponding test to verify the concurrent sending functionality.
2024-11-21 10:26:48 +01:00
181539f8fd
Merge pull request #379 from wneessen/dependabot/github_actions/codecov/codecov-action-5.0.4
Bump codecov/codecov-action from 5.0.2 to 5.0.4
2024-11-20 14:51:16 +01:00
dependabot[bot]
b1a294d364
Bump codecov/codecov-action from 5.0.2 to 5.0.4
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.0.2 to 5.0.4.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](5c47607acb...985343d705)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-20 13:12:42 +00:00
9410381bfc
Merge pull request #378 from wneessen/feature/quicksend
Add QuickSend feature
2024-11-19 17:46:22 +01:00
f05654d5e5
Add exclusion rule for TLS settings in tests
Updated the .golangci.toml config to exclude gosec rule G402 in quicksend_test.go. This exclusion is intentional as these tests do not require TLS settings.
2024-11-19 17:29:37 +01:00
7ee4e47c8e
Add EchoBuffer to serverProps for capturing SMTP data
Introduced a new io.Writer field `EchoBuffer` and its associated `BufferMutex` to `serverProps`. Updated relevant test code to write SMTP transaction data to `EchoBuffer` if it is set, ensuring thread safety with `BufferMutex`.
2024-11-19 17:29:26 +01:00
d30a4a73c6
Add QuickSend function and unit tests
Introduce the QuickSend function for sending emails quickly with TLS and optional SMTP authentication. Added comprehensive unit tests to ensure QuickSend works correctly with different authentication mechanisms and handles various error scenarios.
2024-11-19 17:29:17 +01:00
25a0fb23a9
Merge pull request #377 from wneessen/dependabot/github_actions/step-security/harden-runner-2.10.2
Bump step-security/harden-runner from 2.10.1 to 2.10.2
2024-11-19 15:13:14 +01:00
dependabot[bot]
93fc646338
Bump step-security/harden-runner from 2.10.1 to 2.10.2
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.10.1 to 2.10.2.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](91182cccc0...0080882f6c)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-19 13:32:14 +00:00
f37ab2457b
Merge pull request #376 from wneessen/feature/embed-fs-to-io-fs
Support attachments/embeds via io/fs.FS
2024-11-19 11:00:14 +01:00
101a35f7d3
Add AttachFromIOFS and EmbedFromIOFS functions
Introduce new methods AttachFromIOFS and EmbedFromIOFS to handle attachments and embeds from a general file system (fs.FS). Updated tests to cover these new functionalities and modified error messages for consistency. Updated README to reflect support for fs.FS.
2024-11-19 10:52:54 +01:00
b137fe4611
Refactor file handling to use io/fs interface
Updated functions to use the io/fs package instead of embed.FS, making the code more flexible with respect to different filesystem implementations. Revised the method signatures and related documentation to reflect this change.
2024-11-18 16:44:00 +01:00
bcc32526b7
Merge pull request #375 from wneessen/dependabot/github_actions/codecov/codecov-action-5.0.2
Bump codecov/codecov-action from 5.0.1 to 5.0.2
2024-11-18 15:26:26 +01:00
dependabot[bot]
95ae33255f
Bump codecov/codecov-action from 5.0.1 to 5.0.2
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.0.1 to 5.0.2.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](3b1354a6c4...5c47607acb)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-18 13:46:16 +00:00
0c1908d7bf
Merge pull request #374 from wneessen/feature/auth-autodisover-unmarshal
Add support for SMTP auto-discovery authentication
2024-11-16 22:10:51 +01:00
f296f53c1e
Add support for SMTP auto-discovery authentication
Extended the `UnmarshalString` function in `auth.go` to recognize "auto", "autodiscover", and "autodiscovery" as `SMTPAuthAutoDiscover`. Corresponding test cases were also added to `auth_test.go` to ensure proper functionality.
2024-11-16 21:58:58 +01:00
c37ed7c723
Merge pull request #373 from wneessen/feature/smtp-auth-autoselect
Add SMTP authentication auto-discovery
2024-11-16 21:51:23 +01:00
d8df26bbc8
Fix regression 2024-11-16 21:46:46 +01:00
427e8fd1ed
Format code block consistently
Refactor the `preferList` definition in `client.go` for improved readability and consistency. This change ensures the code aligns with standard formatting practices.
2024-11-16 21:41:32 +01:00
6d3640a166
Fix auth type auto-discovery and add test cases
Refactor the auth type initialization to prevent incorrect assignments and handle empty supported lists. Added comprehensive test cases to verify auto-discovery selection of the strongest authentication method and ensure robustness against empty or invalid input.
2024-11-16 21:38:29 +01:00
ac9117dc50
Add SMTP authentication auto-discovery
Implemented a mechanism to automatically discover and select the strongest supported SMTP authentication type. This feature simplifies the authentication process for users and enhances security by prioritizing stronger mechanisms based on server capabilities. Corresponding tests and documentation have been updated.
2024-11-16 14:29:34 +01:00
a4fa95f7ca
Merge pull request #371 from wneessen/dependabot/github_actions/codecov/codecov-action-5.0.1
Bump codecov/codecov-action from 4.6.0 to 5.0.1
2024-11-15 16:08:58 +01:00
266f0b36ec
Merge pull request #372 from wneessen/dependabot/github_actions/github/codeql-action-3.27.4
Bump github/codeql-action from 3.27.3 to 3.27.4
2024-11-15 16:08:37 +01:00
dependabot[bot]
1cddf5bc76
Bump github/codeql-action from 3.27.3 to 3.27.4
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.27.3 to 3.27.4.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](396bb3e453...ea9e4e3799)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-15 14:02:51 +00:00
dependabot[bot]
7210d679db
Bump codecov/codecov-action from 4.6.0 to 5.0.1
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.6.0 to 5.0.1.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](b9fd7d16f6...3b1354a6c4)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-15 14:02:43 +00:00
e8b41f4a81
Merge pull request #370 from wneessen/feature/golangci-lint-gosec
Enable gosec linter and add exclusion rules
2024-11-15 12:38:55 +01:00
6fbb88239f
Enable gosec linter and add exclusion rules
Added gosec to the list of enabled linters in `.golangci.toml`. Defined specific exclusion rules to ignore certain false positives and context-specific issues flagged by gosec, ensuring the linter does not impose on intentional code practices.
2024-11-15 12:35:15 +01:00
441d163e38
Merge pull request #369 from wneessen/dependabot/github_actions/fsfe/reuse-action-5.0.0
Bump fsfe/reuse-action from 4.0.0 to 5.0.0
2024-11-14 14:55:16 +01:00
dependabot[bot]
1a811f3bcf
Bump fsfe/reuse-action from 4.0.0 to 5.0.0
Bumps [fsfe/reuse-action](https://github.com/fsfe/reuse-action) from 4.0.0 to 5.0.0.
- [Release notes](https://github.com/fsfe/reuse-action/releases)
- [Commits](3ae3c6bdf1...bb774aa972)

---
updated-dependencies:
- dependency-name: fsfe/reuse-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-14 13:50:11 +00:00
da6bf26405
Merge pull request #368 from wneessen/feature/365_expose-error-code-in-senderror
Expose error code in SendError
2024-11-14 10:49:59 +01:00
2bde340428
Update SMTP test port variable and CI configuration
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.
2024-11-14 10:45:35 +01:00
a70dde5a4d
Add TEST_BASEPORT environment variable to CI workflow
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.
2024-11-14 10:41:10 +01:00
ca3f50552e
Allow configuration of test server port via environment variable
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.
2024-11-14 10:36:24 +01:00
bd655b768b
Refactor SendError initialization for better readability
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.
2024-11-14 10:20:52 +01:00
c8d7cf86e1
Enhance error handling in Client's Send method
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.
2024-11-14 10:17:18 +01:00
a5ac7c3370
Update error handling to include error code and status
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.
2024-11-13 23:04:39 +01:00
719e5b217c
Enhance error handling with ENHANCEDSTATUSCODES check
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.
2024-11-13 23:02:30 +01:00
f367db0278
Refactor error code functions and add enhanced status code tests
Renamed `getErrorCode` function to `errorCode` for consistency. Added new tests for the `enhancedStatusCode` function to validate its behavior with various error scenarios.
2024-11-13 22:53:18 +01:00