Commit graph

43 commits

Author SHA1 Message Date
0cf9efcc69
Update SMTP authentication mechanisms and related tests
Introduced the SMTPAuthNoAuth mechanism in the auth.go file meant for instances where authentication is not required or supported. Adjusted tests in client_test.go to account for this new mechanism. Minor order modifications were also made to the list of supported SMTP AUTH types and respective tests for better consistency.

Closes #176
2024-02-22 15:24:19 +01:00
1efac7fb67
Add new test cases for client functionalities and clean client code
Test cases have been added for numerous client functionalities including WithTLSPortPolicy option for the NewClient method, Client.SetSSLPort method, and the Client.DialWithContext method with the fallback port functionality. Minor code simplification has also been performed in the 'SetSSLPort' function in client.go file.
2024-01-31 11:22:01 +01:00
4a90c2de62
Add additional SSL and TLS tests in client_test.go
Enhanced the unit tests in client_test.go by adding more test cases for SSL Port and TLS Port Policy. These additions contribute to more effective coverage of edge cases and increase the robustness of the test suite.
2024-01-25 16:56:15 +01:00
6746af4605
Update client tests for message delivery indication
This commit adds checks in the testing functions to verify the successful implementation of message delivery status. A new attribute `isDelivered` is now being validated in our tests, reinforcing the message tracking system and enhancing the overall reliability of our application.
2024-01-23 11:21:56 +01:00
Nicola Murino
61b9e59dd2 oauth2: add more test cases 2023-06-04 10:47:19 +02:00
sters
e757327e1d
Adding WithDialContextFunc client option 2023-04-19 23:20:33 +09:00
6633591b51
Implement Logger interface
As stated in https://github.com/wneessen/go-mail/pull/102#issuecomment-1411956040 it would be beneficial if, instead of forcing the Go stdlib logger on the user to provide a simple interface and use that for logging purposes.

This PR implements this simple log.Logger interface as well as a standard logger that satisfies this interface. If no custom logger is provided, the Stdlog will be used (which makes use of the Go stdlib again).

Accordingly, a `Client.WithLogger` and `Client.SetLogger` have been implemented. Same applies for the smtp counterparts.
2023-02-03 10:19:26 +01:00
63d8cef8ca
Refactor DSN handling from client.go to smtp.go
This PR refactors the the DSN (RFC 1891) SMTP client handling, that was introduced in f4cdc61dd0.

While most of the Client options stay the same, the whole workaround logic for the SMTP client has been removed and added as part of the SMTP client instead.

This was we got rid of the Client's own `mail()`, `rcpt()`, `dsnRcpt()`, `dsnMail()` methods as well as the copies of the `cmd()` and `validateLine()` methods. The Client is now using the proper `Mail()` and `Rcpt()` methods of the SMTP client instead.
2023-01-18 10:30:06 +01:00
3922d3f195
Switched copyright header from me to "The go-mail Authors" 2023-01-15 16:14:19 +01:00
e36511e90e
Fix tests to not log authentication data
We don't want to expose SMTP authentication details in tests, therefore the tests have been adjusted a bit
2023-01-14 13:05:04 +01:00
34b432a985
Implement debug logging in SMTP client
Resolves #101.

Since we now have full control over the SMTP client we can also access the message input and output.

This PR introduces a new debug logging feature. Via the `Client.WithDebugLog` the user can enable this feature. It will then make use of the new `smtp/Client.SetDebugLog` method. Once the flag is set to true, the SMTP client will start logging incoming and outgoing messages to os.Stderr.

Log directions will be output accordingly
2023-01-14 12:47:51 +01:00
f782f3f4fc
Merge branch 'main' into feature/97_fork-the-netsmtp-package-from-stdlib-into-go-mail 2023-01-12 01:31:36 +01:00
2f053ed8ab
#98 Set up FreeBSD tests via CirrusCI
Need to debug the test-host for cirrus
2023-01-12 01:01:33 +01:00
0d6777ab39
Fork net/smpt into go-mail
As part of #97 we are going to fork the official `net/smtp` package into go-mail to provide us with more flexibility.

This commit fulfills the first big step of importing the package into smtp/. Also go-mail's own LoginAuth has been moved from auth/ into smtp/ to be consistent with the stdlib.

There are still a couple of open issues (i. e. license adjustments and making golangci-lint happy) but so far all tests already work, which is a good start.
2023-01-10 00:38:42 +01:00
862749f863
Fix SMTP AUTH LOGIN method for servers with uncommon success messages
This fixes #94 and basically reverts d0f0435. As James points out correctly in #94, we should not assume specific responses from the server. As long as the spec is followed and the server returns the correct SMTP code, we should not do our own magic.

I've also extended the `getTestConnection` method in client_test.go, so that we can specify more test environment options like `TEST_PORT` and `TEST_TLS_SKIP_VERIFY`. This was needed for testing with the ProtonMail Bridge which listens on a different port and has non-trusted certificates.
2023-01-07 11:31:46 +01:00
b12b0bb363
Update client_test.go
Co-authored-by: iwittkau <iwittkau@users.noreply.github.com>
2023-01-02 22:22:31 +01:00
2c7ea3e532
More changes in regard to #90
As proposed by @iwittkau the `SendError` type now has a `IsTemp()` method as well indicating to the user if the delivery error is retryable or not.

Since we want to use it in the error response from the Client functions like `Send` or `DialAndSend` we need to return the SendError type not only as part of the `*Msg` but also as return value for these methods. Hence, the changes made for #85 been overhauled to return the new error type instead. In the pre Go1.20 version of the `Send()` method we need to return an accumulated version of the SendError type, since we don't have `errors.Join()` and therefore, if more than one error occurred during the delivery we return an ambiguous error reason since we can't tell which of the captured errors is main error. For more details the user can always check the `*Msg.SendError`
2023-01-02 12:14:14 +01:00
78df991399
Proposal change for #90
Did a complete overhaul of the senderror.go.

- the list of `errors.New()` has been replaced with constant itoa error reasons as `SendErrReason`. Instead, the `Error()` method now reports the corresponding error message based on the reason.
- The `SendError` received a `Is()` method so that we can use `errors.Is()` for very specific error checking. I.e. we can check for `&SendErrors{Reason: ErrSMTPMailFrom, isTemp: true}`. This provides much more flexibility in the error checking capabilities
- A `isTemp` field has been added to the `SendError` type, indicating whether the received error is temporary and can be retried or not. Accordingly, the `*Msg` now has a `SendErrorIsTemp()` method indicating the same. The decision is based on the first 3 characters returned from the SMTP server. If the error code is within the 4xx range, the error is seen as temporary
- A test for the SendError type has been added
2023-01-01 14:20:13 +01:00
47bff15de9
Introduction of a Msg error type as proposal for #90
This PR introduces the `SendError` type which implements the error interface.

A new `senderror` field has been added to the `Msg` as well, so introduce this type to it.

I've also added different error variables that indicate the different things that can go wrong during mail delivery. These variables can be checked for, for each `Msg` using the `errors.As` method

The `Error()` method of `SendError` will return a detailed error string on why the `Msg` could not be delivered.

Additionally, `HasSendError()` and `SendError()` methods have been added to `Msg`. While `HasSendError()` simply returns a bool in case a `Msg` failed during delivery, the `SendError()` will return the full `SendError` error interface.
2022-12-31 12:40:42 +01:00
James Elliott
567276d75d
feat: without noop option
This allows disabling the Noop command during the dial. This is useful for servers which delay potentially unwanted clients when they perform commands other than AUTH.
2022-12-27 00:06:20 +11:00
48b4dc6b6c
Fix #85: Client.Send() failing for all messages if one is broken
`Client.Send()` provides the possibility to send multiple `*Msg` in one go. If one of the `*Msg` caused an error with the sending mail server, we were returning completely, while not processing any `*Msg` that came after the failing message.

This PR fixes this behaviour by processing each message first and then return a accumulated error in case any of the `*Msg` processing failed

Additionally, this PR separates the `Client.Send()` method into two different versions. One that makes use of the new `errors.Join()` functionality that is introduced with Go 1.20 and one that handles it the old way for any supported version lower than Go 1.20
2022-12-10 13:41:00 +01:00
d200e982bf
Make golangci-lint errorlint happy 2022-10-17 18:16:00 +02:00
94ad8af58a
Make golangci-lint gofumpt happy 2022-10-17 18:13:00 +02:00
f53579fcf9
Closes #54
- Adds `DialAndSendWithContext()` and makes `DialAndSend()` use the new method
2022-09-26 10:40:57 +02:00
7b030473a6
Final set of unit tests for DSN 2022-09-12 09:31:42 +02:00
c52a437f7f
More tests 2022-09-11 22:05:43 +02:00
aed71397c0
Implemented DSNs as described in RFC 1891
- Added test coverage for the WithDSN* methods
- Updated README.md accordingly
2022-09-11 21:07:15 +02:00
31001e87b2
#24: Add SPDX license IDs for REUSE compliance
# SUMMARY

* Bad licenses:
* Deprecated licenses:
* Licenses without file extension:
* Missing licenses:
* Unused licenses:
* Used licenses: CC0-1.0, MIT
* Read errors: 0
* Files with copyright information: 45 / 45
* Files with license information: 45 / 45

Congratulations! Your project is compliant with version 3.0 of the REUSE Specification :-)
2022-06-17 15:05:54 +02:00
4b99a9e830
More tests for client.go 2022-03-21 12:18:08 +01:00
db496f61cb
More tests for client.go. +80% coverage is probably the most we can get 2022-03-21 10:38:22 +01:00
f15d3ca25e
Add actual mail sending test to client_test.go 2022-03-21 10:17:48 +01:00
e909bd5499
More tests. 50% overall coverage now 2022-03-18 15:05:33 +01:00
b00116c892
More tests. 100% header.go coverage 2022-03-18 10:15:02 +01:00
fcd1bb8d12
Starting with client testing 2022-03-16 21:32:51 +01:00
1c699da955
More tests. Also testing GH's behaviour on ENV variables for testing 2022-03-16 21:02:31 +01:00
ec162e7836
More tests for client.go 2022-03-16 14:09:50 +01:00
a0ebc5bd78
More and better tests for client.go 2022-03-15 22:37:55 +01:00
ecfb966de6
Test fixed 2022-03-15 21:50:25 +01:00
fe3925c1e6
More tests coverage for client.go 2022-03-15 21:48:36 +01:00
2e1b27aec6
Adding more tests... coverage for client.go is now 30% 2022-03-15 21:10:29 +01:00
6285b5fb4f
More progress... calling it a day. 2022-03-09 16:52:23 +01:00
b3554a9578
Slow progress 2022-03-07 16:24:49 +01:00
2fcc0f59cd
Adding first tests 2022-03-06 15:15:42 +01:00