The list of common content types in encoding.go has been revised. The type "multipart/alternative" has been added and the order of types has been adjusted for consistency with net/smtp upstream.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
Added `time` import in the eml_test.go and added two new test use-cases: `exampleMailPlainNoEncInvalidDate` and `exampleMailPlainNoEncNoDate`. The `exampleMailPlainNoEncInvalidDate` is used to check if the parser can correctly handle email with invalid date. Meanwhile, `exampleMailPlainNoEncNoDate` checks if the parser can correctly add the current date to an email that didn't specify a date. This will improve the parser's resilience and flexibility in handling various email scenarios.
The test emails in the eml_test.go file have been updated with more diverse fields, including variations of encoding types. These changes help improve the robustness of our parser tests by evaluating its function with a wider range of email structures. Tests including quoted-printable and base64 encoded emails have been added.
A new test `TestEMLToMsgFromString` was added to "eml_test.go". This test asserts the proper functionality of `EMLToMsgFromString` method that allows us to parse EMLs directly from a string input. This test is a necessary part of ensuring the functionality and reliability of our EML parsing process.
Added two new methods `EMLToMsgFromString` and `EMLToMsgFromReader` in "eml.go". They allow EML parsing directly from a given string and a reader object, increasing overall functionality and versatility of the EML parsing process. This will enable the users to parse EML documents more flexibly."
This commit changes the usage of error value and improves the string comparison for encoding types in EML file parsing. It ensures file closure after read operations to avoid memory leaks. Error messages are made dynamic for improved error reporting. Comments on function has also been made more descriptive.
Added support for quoted-printable encoding in email parser to increase its functionality. The change includes a case handling feature for 'EncodingQP' and related conversions to allow for proper message body reading and encoding setting. This improves the robustness and the scope of email content types that the parser can handle."
Renamed field 'Mime10' to 'MIME10' across multiple files for canonical representation and consistency with standard MIME naming format in the protocol."
Added "References" header field to cover more potential use cases and enhance versatility. This field will allow applications to track series of related messages.
Test for "References" field has also been added for validation.
Also included are string methods for Content-type objects with relevant tests, ensuring accurate string conversion. Unnecessary duplicate method of string conversion for Charset has been removed to streamline the code and improve readability.
We can no parse simple mails (multipart is not working yet). The existing implementation was made more efficient by refactoring the EML file parsing and header extraction mechanism. Added 'strings' and 'bytes' packages to facilitate these changes. Previously, headers and body were parsed separately which was unnecessarily complex and increased the chance of errors. Now, with the new function 'readEML' and the helper function 'parseEMLBodyParts', we are able to parse headers and body together which not only simplifies the code but also increases its reliability. Specifically, 'bytes.Buffer' now helps us capture body while parsing, which removes need for separate handling. Additionally, certain headers like 'charset' and body types are also accounted for in the new implementation, enhancing the completeness of information extracted from EML files.
The diff modifies how the email library handles the extraction of the mime media type from an email header. It uses the mime.ParseMediaType function to parse the content type header. The function gives back the media type as a string and a mapping of different associated parameters. This mapping was previously just printed, but now the charset parameter is also used for setting the charset of the email if it exists.
Added two new functions `EMLToMsg` and `readEML` to the `mail` package. `EMLToMsg` function opens and parses a .eml file and returns a pre-filled Msg pointer. `readEML` opens an EML file and uses net/mail to parse the header and body. These changes are made to provide support for EML file parsing, which is a common requirement in many email-based applications.