-
Notifications
You must be signed in to change notification settings - Fork 100
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
MailBuilder.Build() requires non-empty subject #160
Comments
The goal of the builder was to help people create well formed emails. While an email without a subject is valid, it is not well formed in my opinion. Is there a use case that would help me understand why you want to do this? |
@jhillyerd Thanks for the quick reply! Not sure what the distinction is between "valid" and "well formed"... The use case I ran into is needing to reconstruct an Office 365 (Outlook) envelope. When I do this for Gmail, I can simply call It seems reasonable that you'd be able to use |
The builder has many other "style" limitations you may not be aware of, so this is inline with its design philosophy. Adding a Send() method to Envelope (see also #158) would probably be a better approach to allowing generation of more specialized emails. |
I've run into this trying to do a similar thing as @zeldrinn . Perhaps builder could have a flag to make this check optional for folks who know they do in fact want to send an email with an empty subject line. |
Given this use case is more common than I expected, I think we can just remove the subject check. |
This is valid for email systems and sometimes necessary, especially when you don't have direct control over the souce input. Fixes #160
What I did: Tried to call
MailBuilder.Build()
on aMailBuilder
with an empty string for thesubject
field.What I expected: I expected to be able to build an email object with an empty subject, as plenty of real world emails have empty subjects.
What I got: Received error
subject not set
(https://github.com/jhillyerd/enmime/blob/v0.6.0/builder.go#L220)Release or branch I am using: v0.6.0
It's not clear to me why the validation logic in
Build()
would require subject to be non-empty.The text was updated successfully, but these errors were encountered: