Commit graph

354 commits

Author SHA1 Message Date
8559e8c301
Re-introduce backwards compatibility with Go 1.17 and Go 1.18
The following changes make use of methods that are not available in Go 1.17/Go 1.18. To guarantee at least 4 versions of backwards compatibility, versioned copies of those changes have been back-ported:
- 4d8db00641 (diff-4f6f6bdb9891d4dd271f9f31430420a2e44018fe4ee539576faf458bebb3cee4)
- 58158e990f (diff-772fc9f5d0c86f26e35158fb3e7a71a4967d18b4ec23a5dbb60781ab0babf426)
2023-01-13 17:34:41 +01:00
7cb34856a3
Adjusting license headers and including original LICENSE file from the Go project into the smtp/ directory as suggested in https://github.com/wneessen/go-mail/issues/97#issuecomment-1381046444 2023-01-13 16:54:55 +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
a7126b4201
Merge pull request #99 from wneessen/98-set-up-freebsd-tests-via-cirrus-ci
Set up FreeBSD tests via CirrusCI
2023-01-12 01:30:17 +01:00
09d7f1a4c4
#98 Set up FreeBSD tests via CirrusCI
Since we skip the sendmail test, we don't need postfix anymore
2023-01-12 01:22:45 +01:00
64dde76a58
#98 Set up FreeBSD tests via CirrusCI
Cirrus seems to kill the sendmail test, let's make it skip-able
2023-01-12 01:19:24 +01:00
433980a584
#98 Set up FreeBSD tests via CirrusCI
Apparently we can't provide the secrets environment to CirrusCI, so we cannot perform the send tests
2023-01-12 01:10:08 +01:00
d781217f07
#98 Set up FreeBSD tests via CirrusCI
Cirrus does not understand the double {{}}
2023-01-12 01:05:10 +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
4480a2bfa7
#98 Set up FreeBSD tests via CirrusCI
The .. didn't do anything but fail
2023-01-12 00:54:26 +01:00
4198664737
#98 Set up FreeBSD tests via CirrusCI
We need the environment also it starts in auth/ which is weird
2023-01-12 00:52:01 +01:00
570ccca98f
#98 Set up FreeBSD tests via CirrusCI
Since we already used CirrusCI in the beginning, we only need to modify the existing file.
2023-01-12 00:45:40 +01:00
820d1c25d8
Fork net/smpt into go-mail
Implemented negative check for AuthLogin Auth method
2023-01-11 20:35:22 +01:00
df7bb9b742
Fork net/smpt into go-mail
Fix open TODO in smtp_test.go and fork `testenv.SkipFlaky()` from `internal/testenv` to implement flaky test skipping for FBSD
2023-01-11 20:07:03 +01:00
8e807c2569
Fork net/smpt into go-mail
Fixed open issues in smtp_test.go
2023-01-11 15:28:33 +01:00
1836f6c49d
Start fixing golangci-lint findings in test suite 2023-01-10 16:55:47 +01:00
a804e4a101
Fix license SPDX headers for forked net/smtp code
- Also import the original BSD-3-Clause.txt license from the Go team into the LICENSES directory
- Further on, license headers should hold "The go-mail Authors" instead of my name. Did this already for the MIT license.
2023-01-10 10:09:45 +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
1e959a591d
Update doc.go
Bump version to 0.3.8
2023-01-07 11:58:11 +01:00
fb1d3197c8
Merge pull request #95 from wneessen/94-login-auth-next-handler-should-unconditionally-succeed-if-more-is-false
Fix SMTP AUTH LOGIN method for servers with uncommon success messages
2023-01-07 11:57:46 +01:00
39a9949e78
Fix auth_test.go accordingly
Removed "2.7.0 Authentication successful" challenge since this should never be sent with `more == true`.
2023-01-07 11:48:59 +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
3b3c1e6e8d
Merge pull request #91 from wneessen/feature/90_provide-a-way-of-knowing-which-emails-failedsucceeded-in-sending
Introduction of new error type for sending errors
2023-01-03 11:22:32 +01:00
3d0939b597
Bump version to 0.3.7 for new release 2023-01-03 11:19:07 +01:00
5897bddd11
Update msg.go
Co-authored-by: iwittkau <iwittkau@users.noreply.github.com>
2023-01-02 22:29:10 +01:00
dbb596893d
Update msg.go
Co-authored-by: iwittkau <iwittkau@users.noreply.github.com>
2023-01-02 22:28:39 +01:00
b12b0bb363
Update client_test.go
Co-authored-by: iwittkau <iwittkau@users.noreply.github.com>
2023-01-02 22:22:31 +01:00
e6b73c2397
Update client_119.go
Co-authored-by: iwittkau <iwittkau@users.noreply.github.com>
2023-01-02 22:21:23 +01:00
8d86c3d8b2
Better test coverage for senderror.go 2023-01-02 21:55:37 +01:00
b8ee25f014
Simplify error return to make golangci-lint happy 2023-01-02 20:49:35 +01:00
8463f8524a
Fix merge conflict 2023-01-02 12:16:47 +01:00
b8af7a6ffc
Merge remote-tracking branch 'origin/feature/90_provide-a-way-of-knowing-which-emails-failedsucceeded-in-sending' into feature/90_provide-a-way-of-knowing-which-emails-failedsucceeded-in-sending
# Conflicts:
#	senderror.go
2023-01-02 12:15:39 +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
15b3a0028a
Fix/optimize isTempError method
Not that this particular part of the code is performance critical, but I figured that the `strconv.Atoi()` is actually useless in here.

Since all we want to know is if the error code from the SMTP server is a 4xx error, we can just check the first rune of the returned error. The `Atoi` provides us with no advantage over the simple rune compare (except of taking about 3ns longer to execute)
2023-01-01 20:35:21 +01:00
43efd6b3a8
Add missing REUSE header in senderror_test.go 2023-01-01 14:25:44 +01:00
f6709e90cd
Make golangci-lint happy by using errors.As instead of using type assertion on error (which can fail on wrapped errors) 2023-01-01 14:25:00 +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
42a1fde51f
Fix missing REUSE license header in senderror.go 2022-12-31 12:47:20 +01:00
88eb4c5663
I think it's fair that we reset the Msg.senderror to nil before we Client.Send it.
Since the send error indicate an error during the mail delivery, in my opinion it should be reset when a re-send is initiated, so that the senderror field always represents the latest delivery error. The send error should be checked after mail delivery and before a retry is started.
2022-12-31 12:46:11 +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
f454ae8c41
Merge pull request #88 from james-d-elliott/feat-without-noop
feat: without noop option
2022-12-26 16:49:38 +01:00
e7b162a295
Merge pull request #87 from james-d-elliott/fix-tls-config
fix: tls config unused with dialer
2022-12-26 16:47:15 +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
James Elliott
b8646489ae
fix: tls config unused with dialer
This ensures the configured tls.Config is used with the tls.Dialer.
2022-12-26 23:48:52 +11:00
6a7d49f1b6
Update doc.go
Bump version to 0.3.6 as preparation for the next release
2022-12-10 13:53:07 +01:00
c571650c97
Merge pull request #86 from wneessen/fix/85_clientsend-returns-is-one-of-the-given-messages-fails
Fix #85: Client.Send() failing for all messages if one is broken
2022-12-10 13:51:35 +01: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
32ac691112
Update doc.go
Bump Version to 0.3.5
2022-11-19 11:33:06 +01:00
2a228c5b08
Merge pull request #83 from wneessen/feature/80_add-getaddrheader
#80: GetAddrHeader and SetGenHeader
2022-11-19 11:31:28 +01:00
17b9d2ccf6
#80: GetAddrHeader and SetGenHeader
This PR introduces two major changes:

* SetHeader and SetHeaderPreformatted have been deprecated in favour of SetGenHeader and SetGenHeaderPreformatted
  As pointed out in #80 the naming was pretty confusing, given that we already have SetAddrHeader. With the new naming convention it should be more clear. For compatibility reasons the old methods have been kept for now but in reality they are just aliases to the new methods
* GetAddrHeader and GetAddrHeaderString have been introduced
  As requested in #80 analogous to GetGenHeader we also need a similar method for the address headers. Since address headers are *mail.Address pointer, we've also added a *String method that will extract the address string and return a string slice instead
  Additionally we're introducing methods for the actual address headers: GetTo, GetFrom, GetCc and GetBcc (with a *String counterpart as well). This way the user has full flexibility. Either they use the more "low-level" GetAddrHeader method or the higher level methods for the corresponding address type
2022-11-19 11:22:20 +01:00