Commit graph

57 commits

Author SHA1 Message Date
d327ca73e4
The new messageID generated with #76 is a bit too long by default. This patch reduces the length 2022-10-26 15:48:48 +02:00
2e60d070a6
Add SetHeaderPreformatted() method
With the SetHeaderPreformatted() method we have the ability to set headers that are already preformatted by the user and will not be altered in the mail message output
2022-10-26 15:33:03 +02:00
8484e557d0
Replace math/rand with crypto/rand
Since the Windows tests were still failing, we are replacing the random number generation with math/rand with random string generation via crypto/rand
2022-10-26 14:05:25 +02:00
5bf0c10525
Randomness apparently not good enough for windows. Tests were failing. This fix improves it 2022-10-26 13:43:51 +02:00
021e003e78
Closes #74
This fix makes sure that generated message IDs via SetMessageID() are truly random and unique
2022-10-26 11:59:03 +02:00
2bd6851c78
Fix in the storage of the original Middleware 2022-10-25 16:56:40 +02:00
6f93e5835e
Introducing MiddlewareType and WriteToSkipMiddleware
For middlewares to be able to access the fully written mail message, we need a way to execute WriteTo without the calling middleware to be handled, otherwise we end up in an infinite loop

Therefore, this PR introduces the MiddlewareType and the corresponding change of the Middleware interface. We now require to return the MiddlewareType when the Type() method on the interface is called

This way we can also introduce the WriteToSkipMiddleware method which takes a MiddlewareType as argument. This will allow us to use a WriteTo call with the initiating Middleware to be skipped
2022-10-25 16:42:18 +02:00
b6beeb5cae
Finalized the Reader type and removed the broken Read() method 2022-10-20 18:26:51 +02:00
183fb347d6
Fix create header maps in case SetHeader or SetAddrHeader is called on an empty Msg type 2022-10-20 18:06:26 +02:00
5faa6dfbd6
We now return a Reader instead of the io.Reader interface 2022-10-20 18:03:57 +02:00
966615584d
Implement a proper io.Reader interface since the current implementation is flawed 2022-10-20 15:52:53 +02:00
Dhia Gharsallaoui
b94a42ebe8
Expose Msg attachments fields 2022-10-12 13:36:52 +02:00
dbe58745be
#60 Working on Get/Set methods to access the Msg part slice
Still some tests needed
2022-10-11 17:05:44 +02:00
cd2ee86846
Added GetGenHeader to the Msg to grant read access to set generic headers (e g. to use in Middlewares) 2022-10-02 12:25:49 +02:00
dhia gharsallaoui
a4733f0618 Implement middleware concept and their test 2022-09-22 18:05:47 +02:00
c1d4dbedee
Remove not needed loop from RequestMDNAddTo 2022-09-09 11:39:08 +02:00
46001dc691
Added support for requesting MDNs as described in RFC 8098 2022-09-09 11:35:45 +02:00
192627f6a5
Closes #29: Allow attaching/embedding from embed.FS
- Added `EmbedFromEmbedFS()` to allow embedding from embed.FS
- Added `AttachFromEmbedFS()` to allow attaching from embed.FS
- Added `fileFromEmbedFS()` as internal method for both other m
  methods to attach/embed the embed.FS file
2022-07-07 10:46:57 +02:00
31001e87b2
#24: Add SPDX license IDs for REUSE compliance
# SUMMARY

* Bad licenses:
* Deprecated licenses:
* Licenses without file extension:
* Missing licenses:
* Unused licenses:
* Used licenses: CC0-1.0, MIT
* Read errors: 0
* Files with copyright information: 45 / 45
* Files with license information: 45 / 45

Congratulations! Your project is compliant with version 3.0 of the REUSE Specification :-)
2022-06-17 15:05:54 +02:00
a50910b943
#21: Add possbility to set dedicated envelope from address
- Added `EnvelopeFrom()` and `EnvelopeFromFormat()` methods analogous to the `From()` `FromFormat()` methods
- Changed MsgWriter logic for envelope from addresses
- Adjusted `Msg.GetSender()` to return the envelope from first and only mail body from if the envelope is not set
2022-06-13 10:18:35 +02:00
95100545d6
#18: Added Msg.WriteToFile which allows storing the Msg in a file 2022-06-06 16:43:04 +02:00
97e1386e36
Code smell fix for #13
SonarQube identified two code smells for duplicate string usage
2022-06-03 12:27:26 +02:00
08cf367772
#13: Avoid nil pointer references in template handling 2022-06-03 11:08:33 +02:00
8919d64ca1
#13: Both html/template and text/template support added
- Switched the previous implementation to support text/template as well as html/template
- Added SetBody*Template() methods to use a template directly as message body
- Added AddAlternative*Template() methods to use a template directly as alternative message part
2022-06-03 10:40:54 +02:00
f24a86a4c6
Fix spelling 2022-06-02 16:22:48 +02:00
645ad2ce93
#13 Allow attaching/embedding templates
Implemented the AttachTemplate and EmbedTemplate methods.
Test coverage and documentation is still to be done
2022-06-01 16:49:34 +02:00
dd02ac229b
Closes #11
This PR adds a `Msg.Read()` method which satisfies the `io.Reader` interface
2022-05-28 10:58:19 +02:00
ebef1fe476
Fixes #8
We were using `io.Copy` to write to the body string/alternative string to the io.Writer. This placed the byte position of the buffer to be at the EOF after the first `WriteTo()` call leaving the output of a 2nd call to `WriteTo()` empty.
2022-05-27 12:47:33 +02:00
inliquid
4fe503d142 - Stderr should be read after closing Stdin
- Fix reading of Stderr contents
- Remove redundand calls to `Close`
2022-05-26 14:37:23 +03:00
fa7066c9cf
Update path to sendmail binary
On most systems sendmail is located in /usr/sbin not /usr/bin
2022-05-25 10:53:37 +02:00
070eb39132
Address #5
For the WriteToSendmail* methods the STDIN pipe should be closed so that a forced EOF is sent to the sending program
2022-05-25 10:46:50 +02:00
894ff7128c
Rename Write() to WriteTo() so it satisfies the io.WriteTo interface 2022-05-24 15:46:59 +02:00
030eba8cfd
Default header and sorting
- Default headers are set in its own method now
- Generic headers are now sorted before being written
2022-03-20 19:11:58 +01:00
b852a5281a
v0.1.6: Fix in writeHeader() and User-Agent
- The writeHeader() method wasn't producing good output for long headers. This has been fixed
- Added a VERSION string to the library
- If both no User-Agent and no X-Mailer header are set, the lib adds a default UA-header
2022-03-20 17:38:46 +01:00
b6d90eac6a
*Reader() methods don't need to check for nil, as the underlying fileFromReader does never return nil 2022-03-19 16:55:30 +01:00
e379128c83
Still trying to fix the GH issues with MacOS' broken pipe 2022-03-18 23:28:11 +01:00
0e00b165f9
WriteToSendmailWithContext tests revealed a race condition which has been fixed 2022-03-18 22:23:03 +01:00
3c642be4eb
Added WriteToSendmailWithCommand which is more generic and takes a command to sendmail
The code of WriteToSendmail has been refactored to return the new WriteToSendmailWithCommand using SendmailPath
2022-03-18 21:07:07 +01:00
709b4e6b91
Switched write functions to return the number of bytes. Due to failing tests in Msg.Write() 2022-03-18 17:08:05 +01:00
f8a9512462
More tests for msg.go 2022-03-18 11:47:50 +01:00
a87577d388
Attachment names should probably be encoded 2022-03-15 12:12:45 +01:00
ce1c37bd16
Check if Attachments/Embeds can be read. If an error occurs don't add them to the mail parts 2022-03-15 11:56:21 +01:00
557a161a12
Fix in address handling and more header related methods 2022-03-14 16:25:24 +01:00
ebd8f94c1f
Make GoLinter happy 2022-03-14 15:30:41 +01:00
54da622bd1
Added WriteToSendmail()/WriteToSendmailWithContext() to allow sending mails via local sendmail binary 2022-03-14 15:26:53 +01:00
3e43819b57
Added SetDateWithValue() as well as Reset() to Msg 2022-03-14 11:50:36 +01:00
1157180369
v0.1.1: Added embeds/attachments 2022-03-14 10:29:53 +01:00
62bf1ae33a
Fix SetEncoding() 2022-03-13 20:01:02 +01:00
3261e4d2af
Added ReplyTo()/ReplyToFormat() 2022-03-13 19:36:24 +01:00
8e31cf0133
Fix for X-Priority 2022-03-13 19:28:40 +01:00