Commit graph

719 commits

Author SHA1 Message Date
dependabot[bot]
94fe71c647
Bump github/codeql-action from 3.25.12 to 3.25.13
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.12 to 3.25.13.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](4fa2a79536...2d790406f5)

---
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-22 13:49:10 +00:00
8ea825ce1d
Merge pull request #260 from wneessen/dependabot/github_actions/step-security/harden-runner-2.9.0
Bump step-security/harden-runner from 2.8.1 to 2.9.0
2024-07-19 15:19:35 +02:00
dependabot[bot]
47e901d80d
Bump step-security/harden-runner from 2.8.1 to 2.9.0
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.8.1 to 2.9.0.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](17d0e2bd7d...0d381219dd)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-19 13:18:49 +00:00
ee3f0f1284
Merge pull request #258 from wneessen/dependabot/github_actions/actions/dependency-review-action-4.3.4
Bump actions/dependency-review-action from 4.3.3 to 4.3.4
2024-07-12 16:00:53 +02:00
b7364ae3d6
Merge pull request #259 from wneessen/dependabot/github_actions/github/codeql-action-3.25.12
Bump github/codeql-action from 3.25.11 to 3.25.12
2024-07-12 16:00:33 +02:00
dependabot[bot]
58c0f034bc
Bump github/codeql-action from 3.25.11 to 3.25.12
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.11 to 3.25.12.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](b611370bb5...4fa2a79536)

---
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-12 13:59:26 +00:00
dependabot[bot]
35b3f6eba0
Bump actions/dependency-review-action from 4.3.3 to 4.3.4
Bumps [actions/dependency-review-action](https://github.com/actions/dependency-review-action) from 4.3.3 to 4.3.4.
- [Release notes](https://github.com/actions/dependency-review-action/releases)
- [Commits](72eb03d02c...5a2ce3f5b9)

---
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-07-12 13:59:17 +00:00
850ea90d6b
Merge pull request #257 from wneessen/dependabot/github_actions/actions/setup-go-5.0.2
Bump actions/setup-go from 5.0.1 to 5.0.2
2024-07-11 15:43:37 +02:00
dependabot[bot]
e8b7d0825f
Bump actions/setup-go from 5.0.1 to 5.0.2
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.0.1 to 5.0.2.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](cdcb360436...0a12ed9d6a)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-11 13:36:12 +00:00
2cb54edc95
Merge pull request #256 from wneessen/dependabot/github_actions/actions/upload-artifact-4.3.4
Bump actions/upload-artifact from 4.3.3 to 4.3.4
2024-07-08 15:28:50 +02:00
dependabot[bot]
132fe02384
Bump actions/upload-artifact from 4.3.3 to 4.3.4
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.3 to 4.3.4.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](65462800fd...0b2256b8c0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-08 13:18:08 +00:00
e552e17a74
Merge pull request #255 from wneessen/dependabot/github_actions/fsfe/reuse-action-4.0.0
Bump fsfe/reuse-action from 3.0.0 to 4.0.0
2024-07-04 15:45:03 +02:00
dependabot[bot]
307c7de311
Bump fsfe/reuse-action from 3.0.0 to 4.0.0
Bumps [fsfe/reuse-action](https://github.com/fsfe/reuse-action) from 3.0.0 to 4.0.0.
- [Release notes](https://github.com/fsfe/reuse-action/releases)
- [Commits](a46482ca36...3ae3c6bdf1)

---
updated-dependencies:
- dependency-name: fsfe/reuse-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-04 13:42:06 +00:00
02308df4fd
Merge pull request #254 from wneessen/dependabot/github_actions/sonarsource/sonarqube-scan-action-2.3.0
Bump sonarsource/sonarqube-scan-action from 2.2.0 to 2.3.0
2024-07-02 15:53:51 +02:00
dependabot[bot]
09521758db
Bump sonarsource/sonarqube-scan-action from 2.2.0 to 2.3.0
Bumps [sonarsource/sonarqube-scan-action](https://github.com/sonarsource/sonarqube-scan-action) from 2.2.0 to 2.3.0.
- [Release notes](https://github.com/sonarsource/sonarqube-scan-action/releases)
- [Commits](540792c588...aecaf43ae5)

---
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-07-02 13:51:17 +00:00
32a5603496
Merge pull request #253 from wneessen/feature/add_get_boundary
Add GetBoundary method and corresponding test
2024-07-02 11:11:33 +02:00
b88b67e2c7
Add GetBoundary method and corresponding test
The GetBoundary method has been added to the Msg struct in msg.go. Alongside this, a corresponding test method, TestMsg_GetBoundary, was introduced in msg_test.go to ensure the proper working of GetBoundary. This new method returns the boundary string of the Msg, which was previously inaccessible.
2024-07-02 10:58:13 +02:00
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