go-gomail / gomail

The best way to send emails in Go.
MIT License
4.33k stars 573 forks source link

Move message validation out of the Mailer #6

Closed hobeone closed 9 years ago

hobeone commented 9 years ago

Currently the a Message is only checked for validity when it is sent and all the logic for validation is in the Mailer.Send() function. It seems that this might be more useful to pull put either into it's own set of functions or as a function of the Message struct.

This would be useful when you want to check the validity of a message without sending it. - i.e. check that a message is valid and present a user of what they need to fix if it isn't.

alexcesaro commented 9 years ago

There is no real validation done. There are just two types of errors that are currently returned when sending an email: a missing From field and a malformed recipient address.

I do not see the real value of exposing a validation function since checking for a From field is pretty trivial and a well-formed recipient address does not mean the address exists.

What kind of validation would you like?