if you omit the from address for cfmail it throws an error, however, it's only when the mail is spooled, that email addresses are parsed using javax.mail.internet.InternetAddress and maybe set to null if they are invalid.
It would be more developer friendly if these processing/checks via javax.mail.internet.InternetAddress were applied before spooling, i.e when the cfmail tag is called so an exception can be thrown (i.e. invalid email address)
it’s not as simple as just using isvalid('email',) because Mail needs to take a list of addresses for things like the to and cc fields so it’d have to be tokenized too. At least isValid() believes in CC TLD and real names though :)
agreed on isValid, that’s why i have subsequently suggested using the spool validate. It’s always going to be run anyway.
previously Lucee would keep retrying even if the spool validate failed (unlike a delivery problem) so, there’s no mail retrying as it will only fail once.
it does make sense to put this behind a flag, which is disabled by default as developers might not expect an exception sending a mail, unless they are using async=false
adding something like a <cfmail validate=”true|false”> (default false) for this makes sense, then in application.cfc, this.tag.mail.validate=true; could be used to enable it.
changed the implementation
Err, OK, what about the other stuff like making the behaviour change an opt-in option ?
as it was always going to fail whilst spooling anyway, if you don’t really care, you can always just wrap it up in a try, catch and ignore
PR to update cfmail [to] be a required attribute