-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactorings #3
Open
dmke
wants to merge
15
commits into
meehow:master
Choose a base branch
from
digineo:refactorings
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Refactorings #3
+483
−55
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It turns out, a global variable is not a great idea, so we move it into the Mail object itself. This is also introduces a new "chaninable" API: `m.SetSendmail()` returns `m`, which allows chaining of further options (see following commits).
Don't depend on environment variable for debug output, instead let the consumer decide where to print to.
AppendTo might be a bit misleading, as it doesn't append the mail to something, but appends the mail's To field. It is literally a `To = append(To, ...)` construct.
Accepts chainable Options as arguments.
Makes testing unneccessarily hard.
Place multipart mails (HTML+Text) on the roadmap.
WriteTo now returns (int64, error); however the returned number of bytes written is always 0, since we don't get the actual number easily.
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(This is a continuation of #2.)
Hey,
whilst using this more, I found I needed a more conveniant interface.
The first part in this commit series will introduce a
sendmail.Option
type and asendmail.New()
constructor function, which takes said Options as arguments. Together, they allow code to look like this:or like this:
Another subset of the commits moves the recently introduced global
Binary
variable, as well as the debug variable into theMail
type. As it turns out, global variables are a source of frustration in concurrent applications :-) You can see an example in the snippets above (SetOutput
/SetSendmail
).I also started with HTML mails, but mixed-content (multipart, Text+HTML) isn't there yet. I'd like to harvest some code from mailyak, but the current license prevents me from that. Having a solid MIME multipart implementation would also allow attachments to the mail.