Commit graph

702 commits

Author SHA1 Message Date
cf87ea68d3
Merge pull request #252 from wneessen/dependabot/github_actions/github/codeql-action-3.25.11
Bump github/codeql-action from 3.25.10 to 3.25.11
2024-07-01 23:13:35 +02:00
dependabot[bot]
ca0d94c7a7
Bump github/codeql-action from 3.25.10 to 3.25.11
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.10 to 3.25.11.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](23acc5c183...b611370bb5)

---
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-07-01 13:44:21 +00:00
ffdea8337e
Merge pull request #249 from wneessen/feature/145_add-eml-parser-to-generate-msg-from-eml-files
This PR introduces an EML parser to go-mail. It allows to read generic EML data from a file, a string or a reader into a go-mail Msg struct. It supports all types of message parts and encodings. It should be able to recognize Mulitpart messages as well as attachments and embeds (inline attachments).

This PR closes #145
2024-06-28 14:11:30 +02:00
7e4bb00538
Add error handling for writing EML string to temp file
Added conditional statements to handle potential failures when writing the EML string to the temporary files during testing. These updates ensure test failures due to write errors are accurately reflected in test results. Also, a minor fix is implemented on file permission in the os.WriteFile function.
2024-06-28 13:59:08 +02:00
d9290973be
Bump version to 0.4.2 2024-06-28 13:53:00 +02:00
2fa52e5341
Add EML file support to go-mail in README
The README has been updated to show that go-mail now supports outputting a message as an EML file and parsing an EML file into a go-mail message. This addition enhances the flexibility and control over the email content and format.
2024-06-28 13:51:49 +02:00
8924e426d6
Add test for WithFileContentID option
The change introduces a new unit test, TestFile_WithContentID, in file_test.go. This test aims to verify the correct function of the WithFileContentID option by using differing scenarios, with assertions for error control and validation of expected content.
2024-06-28 13:49:34 +02:00
4e7082a540
Rename WithContentID to WithFileContentID
In the eml.go and file.go files, the function WithContentID has been renamed to WithFileContentID. This aligns more accurately with the function purpose, which is to set the content ID for a File object.
2024-06-28 13:49:21 +02:00
ca201b1548
Add tests for various email scenarios
This commit introduces tests for different email scenarios including emails with no boundaries, emails with attachments, emails with embedded items, and multipart mixed emails. The tests ensure that the code correctly returns all expected parts of the email (e.g., embeds, attachments, parts) and that it correctly processes the email subject.
2024-06-28 13:45:22 +02:00
68d0fe9cd3
Remove debug print statement from eml.go
The debug print statement that outputs the content type of the email has been removed from eml.go. This change improves code cleanliness and avoids unnecessary console output in production.
2024-06-28 13:33:57 +02:00
0bf3f73e9b
Update comment in eml.go for parsing multipart messages
The comment in the eml.go file was extended to include the possibility of 'Multipart/alternative' parts. Previously, it only mentioned 'Multipart/related' parts. The actual code functionality remains unchanged, this is purely a clarification in the documentation.
2024-06-28 13:28:57 +02:00
fcc5209852
Add handling for multipart/alternative content type
The EML parser now includes logic to manage 'multipart/alternative' content types. This adjustment is made within the section handling 'multipart/related' parts, allowing for better handling and parsing of varying content types.
2024-06-28 13:28:09 +02:00
84e6275cb2
Add base64 encoding support to email attachments
The updated code adds base64 encoding support to email attachments and inline content in eml.go. It does this by introducing a new dataReader which uses a base64 decoder if the content transfer encoding is base64. With this update, attachments with base64 content will be correctly decoded when processed.
2024-06-28 11:54:30 +02:00
b709df4b2d
Add WithContentID function to file.go
The newly added function, WithContentID, allows for setting the Content-ID header for the File. This provides enhanced handling and differentiation of files.
2024-06-28 11:54:06 +02:00
8b1208949f
Fix multipart header parsing in eml.go
The commit modifies the parseMultiPartHeader function to handle optional fields accurately. The delimiter was changed from "; " to ";" and whitespace is being trimmed from the start of optional fields to ensure correct splitting and mapping.
2024-06-25 10:59:04 +02:00
faab5323fd
Fix erroneous header name in error message
The error message previously referenced a constant 'HeaderTo' which might not always be the header being parsed. The commit replaces this with 'addrHeader', significantly improving the accuracy of error messages.
2024-06-25 09:47:12 +02:00
db9893f15a
More test coverage
Refactored the way EML files are tested, the errors are now handled more efficiently. Temporary directory and file creation, as well as file writing, have been moved to a helper function named 'stringToTempFile'. Moreover, additional test cases were added to ensure proper parsing failure for various types of email-related errors.
2024-06-24 14:30:28 +02:00
0cec8a28f7
Refactor EML parsing into a single function
The previous separate parsing of EML headers and body parts has been refactored into a single function, parseEML. This change simplifies the operations in the readEML and makes the code cleaner by reducing repetition.
2024-06-24 14:30:07 +02:00
9fa8644a9a
More test coverage
New failing tests have been added to 'eml_test.go' to account for a variety of error situations, such as broken FROM, TO, headers, bodies, and unknown or unsupported content types. Improving the robustness of test coverage helps identify potential issues and ensure the resilience and correctness of the code.
2024-06-24 13:42:28 +02:00
70c9387003
Add error handling for unknown content types in eml.go
The update adds a case to the switch clause in eml.go for properly handling unknown content types. An error will now be returned when the media type of the body to be parsed is not recognized, increasing the robustness of the system.
2024-06-24 13:41:48 +02:00
4c88dce2a8
Add test for EMLToMsgFromString with embedded content
The new test ensures that the EMLToMsgFromString function properly handles an EML that contains embedded content. The expected subject content and number of embedded objects are checked to confirm correct parsing.
2024-06-22 14:24:52 +02:00
bb33c4a921
Add support for multipart/related EML parsing
This update expands the EML parser to support multipart/related content types. It also includes relevant error handling and creates a specific routine for parsing multipart/related parts separately. Furthermore, adjustments were made to avoid processing headers unnecessarily when TypeMultipartMixed is used. The diff also shows some refactoring for clearer error messages and cleaner code.
2024-06-22 14:13:26 +02:00
52ef13a5d5
Refactor test cases and remove content print statement
The content print statement in eml.go was removed to optimize code readability and performance. In addition, several assertions in the test cases of eml_test.go were corrected for string formatting errors and a new test case was added for handling emails with attachments. These changes aim to enhance the robustness of tests for email encoding and decoding operations.
2024-06-19 15:25:37 +02:00
e95799ad60
Refactor attachment and embed parsing in EML
The EML parsing has been refactored to separate the handling of attachments and embeds into a new helper function. This improves the organization of the code, makes it easier to understand and helps to better manage error handling and resource closing.
2024-06-19 14:41:13 +02:00
85c07c22cc
Refactor multipart parsing in eml.go
The code is refactored to improve multipart parsing in EML. The `parseEMLMultipartAlternative` function is updated to `parseEMLMultipart` for more general utilization. This involves iterating through the parts of a multipart message until content disposition is found and appended. A new function `parseMultiPartHeader` is introduced to parse multipart header and handle charset more sensibly.
2024-06-19 13:57:00 +02:00
29305675d6
Refactor EML encoding and content-type parsing to separate functions
The commit includes extraction of blocks of code related to EML message encoding and content-type parsing into their own separate functions. By doing so, it improves code readability and maintainability.
2024-06-19 10:52:09 +02:00
04c41a1f10
Add EML message parsing tests
Introduced a new test, `TestEMLToMsgFromFile`, to validate the functions responsible for EML message parsing. This complements the existing `EMLToMsgFromString` test, holding them accountable for subject and encoding accuracy. Also, a temporary directory is now created for testing File-related operations in isolation.
2024-06-19 10:42:29 +02:00
047d923b45
Merge branch 'refs/heads/main' into feature/145_add-eml-parser-to-generate-msg-from-eml-files 2024-06-17 10:01:18 +02:00
d8a3d0b682
Merge pull request #248 from wneessen/dependabot/github_actions/github/codeql-action-3.25.10
Bump github/codeql-action from 3.25.9 to 3.25.10
2024-06-14 15:56:25 +02:00
dependabot[bot]
9a092adfa0
Bump github/codeql-action from 3.25.9 to 3.25.10
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.9 to 3.25.10.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](530d4feaa9...23acc5c183)

---
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-06-14 13:46:10 +00:00
6ad0e472a5
Merge pull request #246 from wneessen/dependabot/github_actions/github/codeql-action-3.25.9
Bump github/codeql-action from 3.25.8 to 3.25.9
2024-06-13 15:51:19 +02:00
7bc849c786
Merge pull request #247 from wneessen/dependabot/github_actions/sonarsource/sonarqube-scan-action-2.2
Bump sonarsource/sonarqube-scan-action from 2.1.0 to 2.2
2024-06-13 15:51:00 +02:00
2bc62c866c
Merge pull request #245 from wneessen/dependabot/github_actions/codecov/codecov-action-4.5.0
Bump codecov/codecov-action from 4.4.1 to 4.5.0
2024-06-13 15:50:36 +02:00
dependabot[bot]
1191060ab7
Bump sonarsource/sonarqube-scan-action from 2.1.0 to 2.2
Bumps [sonarsource/sonarqube-scan-action](https://github.com/sonarsource/sonarqube-scan-action) from 2.1.0 to 2.2.
- [Release notes](https://github.com/sonarsource/sonarqube-scan-action/releases)
- [Commits](86fe817756...540792c588)

---
updated-dependencies:
- dependency-name: sonarsource/sonarqube-scan-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-13 13:50:11 +00:00
dependabot[bot]
9af8ceb037
Bump github/codeql-action from 3.25.8 to 3.25.9
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.8 to 3.25.9.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](2e230e8fe0...530d4feaa9)

---
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-06-13 13:50:07 +00:00
dependabot[bot]
4ac1748a31
Bump codecov/codecov-action from 4.4.1 to 4.5.0
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.4.1 to 4.5.0.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](125fc84a9a...e28ff129e5)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-13 13:49:50 +00:00
e7853b1a58
Merge pull request #244 from wneessen/dependabot/github_actions/step-security/harden-runner-2.8.1
Bump step-security/harden-runner from 2.8.0 to 2.8.1
2024-06-07 16:13:53 +02:00
dependabot[bot]
cedc52f565
Bump step-security/harden-runner from 2.8.0 to 2.8.1
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.8.0 to 2.8.1.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](f086349bfa...17d0e2bd7d)

---
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-06-07 13:25:34 +00:00
8a272c6529
Merge pull request #243 from wneessen/dependabot/github_actions/actions/dependency-review-action-4.3.3
Bump actions/dependency-review-action from 4.3.2 to 4.3.3
2024-06-06 16:13:35 +02:00
dependabot[bot]
33591bb136
Bump actions/dependency-review-action from 4.3.2 to 4.3.3
Bumps [actions/dependency-review-action](https://github.com/actions/dependency-review-action) from 4.3.2 to 4.3.3.
- [Release notes](https://github.com/actions/dependency-review-action/releases)
- [Commits](0c155c5e85...72eb03d02c)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-06 13:40:11 +00:00
2e342f82e7
Merge pull request #241 from wneessen/dependabot/github_actions/github/codeql-action-3.25.8
Bump github/codeql-action from 3.25.7 to 3.25.8
2024-06-05 16:12:29 +02:00
dependabot[bot]
5930d58289
Bump github/codeql-action from 3.25.7 to 3.25.8
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.7 to 3.25.8.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](f079b84933...2e230e8fe0)

---
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-06-05 13:55:29 +00:00
a67a4d625e
Merge pull request #239 from wneessen/dependabot/github_actions/golang/govulncheck-action-1.0.3
Bump golang/govulncheck-action from 1.0.2 to 1.0.3
2024-06-04 16:01:41 +02:00
dependabot[bot]
819d3999f9
Bump golang/govulncheck-action from 1.0.2 to 1.0.3
Bumps [golang/govulncheck-action](https://github.com/golang/govulncheck-action) from 1.0.2 to 1.0.3.
- [Release notes](https://github.com/golang/govulncheck-action/releases)
- [Commits](3a32958c27...dd0578b371)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-04 13:55:49 +00:00
b7bbeab6fe
Merge pull request #238 from wneessen/dependabot/github_actions/github/codeql-action-3.25.7
Bump github/codeql-action from 3.25.6 to 3.25.7
2024-05-31 16:39:56 +02:00
dependabot[bot]
55b199e0c3
Bump github/codeql-action from 3.25.6 to 3.25.7
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.6 to 3.25.7.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](9fdb3e4972...f079b84933)

---
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-05-31 14:05:31 +00:00
481fc1d48c
Refactor variable names in eml.go for clarity
Variable names in eml.go have been refactored for better readability and understanding. Shortened abbreviations have been expanded into meaningful names, and complex object names have been made simpler, making it easier to understand their role within the codebase. Cooperative variable names will improve maintainability and ease future development. This is a follow up to #179 which didn't consider this branch.
2024-05-27 10:59:38 +02:00
34f2141a26
Merge branch 'refs/heads/main' into feature/145_add-eml-parser-to-generate-msg-from-eml-files 2024-05-27 09:56:03 +02:00
661b7dace2
Merge pull request #237 from wneessen/sync_with_upstream
Sync with upstream
2024-05-24 18:58:57 +02:00
071ad66035
Sync with upstream
This PR syncs our smtp package with the upstream `net/smtp` changes introduced via bf91eb3a8b
2024-05-24 18:50:27 +02:00