Commit graph

457 commits

Author SHA1 Message Date
6268077b99
Make golangci-lint happy
Omitting nil redundant nil checks, as len() for []string is defined as zero
2023-11-30 09:14:31 +01:00
5dcbe712ae
Add null check to prevent empty file handle error in msg_test.go
Implemented a null check to ensure the 'fi' file handle is not empty. With the absence of this check, the test was continuing even when 'fi' was empty, leading to null pointer exceptions further down in the code.
2023-11-29 17:47:30 +01:00
ddcad3710d
Fix potential null pointer exceptions in msg_test.go
Added robustness and improved error handling in msg_test.go by adding null checks before calling values from the genHeader map in RequestMDNTo and related functions. This enhancement was necessary to avoid the operations on non-existing keys and potential null pointer exceptions.
2023-11-29 17:46:30 +01:00
fb17547e69
Improve error handling in msg.go
Added additional checks when calling values from the genHeader map in msg.go file. This is to prevent trying to operate on non-existing keys, hence avoiding possible null pointer exceptions. The checks ensure the key HeaderMessageID exists in the genHeader map before attempting to operate on it. This is essential for functions like RequestMDNTo, RequestMDNToFormat, and RequestMDNAddToFormat, thereby improving the robustness of the code.
2023-11-29 17:40:31 +01:00
5a4f814061
Protect against key not found in genHeader map in msg.go
Added checks to ensure the key HeaderMessageID exists in the genHeader map before attempting to operate on it in msg.go. This will prevent possible null pointer exceptions when trying to assign the key a value or append it to the mids slice.
2023-11-29 17:34:15 +01:00
da21550dc9
Fix potential null pointer exceptions in msg.go
This commit adds conditions in msg.go file to check if the header 'HeaderDispositionNotificationTo' key exists in the map 'm.genHeader' before trying to associate it with a value. This prevents potential null pointer exceptions.
2023-11-29 17:26:58 +01:00
fd313e23b6
Add checks for nil or empty Subject headers
Added condition checks in `msg_test.go` for nil or empty Subject headers in the assigned functions. If the Subject is found to be nil or its length is less than 1, an empty string is now appended to prevent issues arising from null pointers or non-existent Subject headers in email messages.
2023-11-29 17:26:47 +01:00
81306e4dd3
Fix null pointer exception in Is function
Updated the Is function in senderror.go to handle null values for SendError. This was done by adding a nil-check for surfaced pointer errors in the errors.As call. This prevents the function from attempting to derive values from a null pointer and consequently prevents null pointer exceptions from being thrown.
2023-11-29 17:20:09 +01:00
b79374224c
Handle nil buffer in Reader and update tests
Updated the Reader struct in reader.go to properly handle nil buffers. This prevents potential errors from nil pointer dereference. Also added the fmt package for debugging purposes. Correspondingly, additional tests in reader_test.go were also added to cover these edge cases and ensure the Reader struct correctly handles them.
2023-11-29 17:18:55 +01:00
b63d4803f1
Refactored null checks in msgwriter.go
Extended null check conditions in msgwriter.go to prevent potential nil pointer dereference. This change ensures robustness in error handling in scenarios where FROM header or envelope FROM is either not existent or nil.
2023-11-29 16:56:32 +01:00
ca896bd641
Refactor error checking in msg.SendErrorIsTemp()
Added an additional condition in the SendErrorIsTemp function within msg.go to ensure that the error e is not nil before referencing it. This guards against potential runtime panics from dereferencing a nil pointer, enhancing robustness of error handling.
2023-11-29 16:45:25 +01:00
a50a3ceb18
Add validation for nil STDERR or STDIN pipe
Introduced a new condition that checks and returns an error if either STDERR or STDIN pipe is nil in the msg function of msg.go. This improves error handling by preventing potential panic due to referencing a nil pipe.
2023-11-29 16:43:50 +01:00
1a166770b7
Update range loop to improve msg function readability
Converted the range loop in the GetAddrHeaderString function in msg.go to use value semantics rather than index notation. This improves code clarity by not unnecessarily referring to m.addrHeader[h] in the loop and instead referencing the value directly (using variable mh), making it easier to understand and maintain.
2023-11-29 16:42:07 +01:00
bb18ef9e93
"Improve error checking in SMTP client creation"
A change was made in the SMTP client creation process to add more robust error handling. The new logic checks if the client is null after being created and, if true, returns an error. This update can help prevent potential null pointer exceptions in runtime, ultimately leading to more stable application.
2023-11-29 16:25:35 +01:00
cf678be9dd
Handle nil pointer in IsTemp method in senderror.go
Added a nil check in the IsTemp method in senderror.go to prevent runtime errors when method is called on a nil object. The method now immediately returns false if it is invoked on a nil *SendError, ensuring the program's robustness against potential misuse. This increases the robustness and readability of the
2023-11-20 18:45:35 +01:00
468e1e2b2c
Protect against empty address list, refactor error handling
Added a condition to prevent assignment of an empty address list to the 'HeaderFrom' scenario. This eliminates potential runtime errors when trying to access an nonexistent element of a slice.
Adjusted error handling in the sendmail execution part by reusing the 'err' variable, promoting cleaner, more readable code.
2023-11-20 18:36:19 +01:00
cdc8c37309
Merge pull request #155 from wneessen/feature/152_recipients_from_single_string
Add new methods and tests for handling email addresses
2023-11-10 18:22:45 +01:00
43c26a37e3
Updated mail.Address initialization in tests to make golangci-lint happy
Tests for new mail address handling methods have been updated to use {Name:"", Address: "email@example.com"} format for initializing the []*mail.Address slices, instead of the previous shorthand {"", "email@example.com"}. This was done to increase code clarity and explicitness.
2023-11-10 18:14:44 +01:00
cc14864129
#152: Add new methods and tests for handling email addresses
Added new methods `ToFromString()`, `CcFromString()` and `BccFromString()` in msg.go file to handle strings of comma-separated email addresses.
2023-11-10 18:07:56 +01:00
cf45f64cc5
Merge pull request #149 from wneessen/feature/147_add-method-to-remove-any-attachmentembed
Feature/147 add method to remove any attachmentembed
2023-10-20 14:21:42 +02:00
a4379a51dc
Merge pull request #148 from leahoop/147_remove_attachments_and_embeds
#147 add remove attachments and embeds methods
2023-10-20 09:50:54 +02:00
leahoop
3c2c106cb4 #147 add remove attachments and embeds methods 2023-10-20 10:21:03 +08:00
0bd5390e37
Update codecov.yml 2023-08-23 11:47:00 +02:00
8f3e5d382c
Merge pull request #143 from wneessen/feature/142_implement-structured-json-logger
#142 Add structured JSON logger and associated tests
2023-08-23 11:46:13 +02:00
77d9e3d02a
#142 Add structured JSON logger and associated tests
This commit introduces a new type 'JSONlog' that satisfies the Logger interface for structured JSON logging. This includes new methods 'Debugf', 'Infof', 'Warnf' and 'Errorf' to log messages at different levels and an associated test 'jsonlog_test.go' to ensure correct functionality. This enhances the logging functionality by providing clarity in logs and eases debugging process.
2023-08-23 11:16:23 +02:00
0189acf1e4
Refactor log level and direction function to separate file
Moved Level constants and directionPrefix() function from log/stdlog.go to log/log.go. This change improves the organization of the code by grouping log level constants and related functions in the same file. Furthermore, this removes redundancy and ensures consistency of log level across different files.
2023-08-15 11:59:16 +02:00
9ee864316a
Merge pull request #141 from wneessen/136_debuglog_refactor
Refactor logging for clearer messaging direction
2023-08-15 11:23:02 +02:00
e0716052e7
Merge branch 'main' into 136_debuglog_refactor 2023-08-15 11:14:42 +02:00
f9b1e46d6d
Remove unnecessary .idea XML configuration files
The deleted .idea XML configuration files (markdown.xml, modules.xml, Project_Default.xml) were not required for the functioning of the project. Removing these files helps in reducing clutter and simplifying the project structure. Also, these files can often contain user-specific settings or paths, and may cause conflicts when working in a team.
2023-08-15 11:13:47 +02:00
c7f3a4ddae
Merge remote-tracking branch 'origin/main' into 136_debuglog_refactor 2023-08-15 11:11:47 +02:00
3ba64d5e28
Merge pull request #140 from wneessen/go-1.21-maintenance
Update Go version to 1.21 in GitHub workflows
2023-08-15 10:16:06 +02:00
b2e54717b3
Update Go version to 1.21 in GitHub workflows
This commit updates the Go version from 1.20 to 1.21 on three GitHub workflow files: golangci-lint.yml, codecov.yml, and sonarqube.yml. The change ensures we use the latest Go version which is more efficient and comes with additional features, leading to improved project performance.
2023-08-15 10:11:13 +02:00
5948b38702
Remove redundant vcs.xml file
The .idea/vcs.xml file was deleted because it is not needed for the project. It was initially created by the IntelliJ IDEA but we're managing version control configurations through another way, making this file redundant.
2023-08-15 10:08:47 +02:00
c2e3613c28
Remove .idea/go-mail.iml, update .gitignore
Deleted the `.idea/go-mail.iml` file which was committed in error and should not be part of the source code repository. Updated the `.gitignore` file to ignore the whole `.idea` directory, since it contains configuration files that are specific to each developers environment and not required for the project build. The changes in the repository will now make it more clutter-free and prevent unintentional commits of unnecessary files in the future.
2023-08-15 10:04:01 +02:00
04aac48288
Merge branch 'main' into 136_debuglog_refactor
# Conflicts:
#	msgwriter.go
2023-08-08 11:13:21 +02:00
05c2105705
Merge pull request #139 from wneessen/bugfix/138_segfault-in-writer-because-createpart-error-is-ignored
Fix nil pointer dereference in msgwriter due to missing error handling
2023-08-08 11:10:31 +02:00
edd6051df3
#138: Add error handling to message writing process
In the updated version of msgwriter.go, an additional error handling process has been included. If an error is detected when creating a new part in the message writer, this error is stored and prevents executing the writeBody function. This fixes nil pointer dereference in `mw.writeBody` if an error occured previously.
2023-08-08 10:59:10 +02:00
39080a8a05
#136: Add error handling to message writing process
In the updated version of msgwriter.go, an additional error handling process has been included. If an error is detected when creating a new part in the message writer, this error is stored and prevents executing the writeBody function. This fixes nil pointer dereference in `mw.writeBody` if an error occured previously
2023-08-08 10:54:38 +02:00
1c5c1e318c
#136: Refactor logging for clearer messaging direction
The logging system in the smtp.go and log package has been refactored. A new custom log type `Log` was introduced, that includes the message direction, format and arguments. The `Logger` interface and the `Stdlog` implementation were modified to accept this new type. This change provides a clearer understanding of message direction inside logs, allowing for easier debugging and reduced complexity. This change does not affect features or disrupt user functionality. Additionally, it allows for custom implementations of the log.Logger interface to without being forced to use the C --> S/C <-- S direction logging.
2023-08-02 11:43:45 +02:00
832c0026b1
Merge pull request #137 from wneessen/logger-readablity
Replace hardcoded '2' in Output with const CallDepth
2023-07-24 16:06:16 +02:00
7d69ec8faa
Replace hardcoded '2' in Output with const CallDepth
A `const CallDepth` placeholder has been introduced and has been set to 2. This is used as an argument in Output method calls in various log levels like debug, info, warn, and error in place of previously hardcoded '2'. This change improves the readability of the code. The '2' represented the call depth of log.Logger's Output method, which wasn't immediately clear with the hardcoded value.
2023-07-24 15:27:39 +02:00
2b27643187
Merge pull request #132 from drakkan/oauth2_test
oauth2: add more test cases
2023-06-04 16:01:42 +02:00
Nicola Murino
61b9e59dd2 oauth2: add more test cases 2023-06-04 10:47:19 +02:00
4100fef083
Merge pull request #131 from wneessen/v0.4.0-prep
Preparation for the v0.4.0 release:
2023-05-31 09:41:01 +02:00
c01788641b
Preparation for the v0.4.0 release:
- Updated discord link
2023-05-31 09:40:51 +02:00
438cfd60eb
Preparation for the v0.4.0 release:
- Bump version in doc.go
- Add sonarlint to .gitignore
- Update README to reflect the changes and contributors
- Fixed typos in auth_cram_md5_118.go, msg.go, msg_test.go, reader.go and smtp_ehlo_117.go
2023-05-31 09:34:45 +02:00
30b20c5049
Merge pull request #130 from drakkan/xoauth2
add Oauth2 support
2023-05-31 09:24:26 +02:00
Nicola Murino
2122186ca3 CI FreeBSD: use the latest 12.x and 13.x versions 2023-05-29 18:22:58 +02:00
Nicola Murino
2a67b397c7 OAuth2: don't send the "*" command to cancel authentication
XOAUTH2 does not follow the SMTP AUTH RFC
2023-05-29 18:21:24 +02:00
Nicola Murino
8673addaf0 OAuth2: remove variants
Microsoft also accept the same protocol used for Google servers
2023-05-29 18:19:01 +02:00