Commit graph

29 commits

Author SHA1 Message Date
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