Email addresses with + signs are treated as errors

I was just testing the bulk invite feature to see what the message was going to be to users and I used my personal Gmail email but added the + sign. The import failed as you can see below (I replaced my actual email address with validaddress).

Email addresses with + signs are perfectly valid according to RFC 2822 spec, so I’d expect Discourse to allow it.

Your bulk user invite file was processed, 0 invites mailed with 1 error(s).

Here’s the log:

[2020-12-09 20:40:21 +0000] Invalid Email 'validaddress+test@gmail.com

This is the regex we use to parse these addresses, I believe:

https://github.com/discourse/discourse/blob/7988a5f14bb656ddb8e0a377acfcd0a8c40939f6/lib/validators/email_validator.rb#L47-L49

Run this through https://rubular.com/ and it shows a perfectly valid email with a + sign.

However, it appears the email you provided may have had an invalid character in it.

'validaddress+test@gmail.com – the ' at the beginning probably caused the bulk invite feature to fail.

5 Likes

Thank you. It’s curious: I saw that apostrophe in the error message too and dismissed it initially. I know Excel does that sometimes to text in a cell when you convert it (I coverted this from XLSL to CSV for import), but I’ve double checked the import file (in VS Code) and don’t see any leading apostrophes.

Thank you for providing the regex and clarifying that it should be allowed. I’ll have to tinker more to see if I can figure out why it’s failing. (It failed even when I deleted that user, removed the +test from the email, and tried to re-send the invite.)

2 Likes

As near as I can tell, that leading apostrophe is part of the error message, not my import file. I went ahead and did a bulk import with 86 actual emails. I received errors in two cases (which is bizarre in its own right because I’ve emailed these people). I removed the specific email for this post.

Your bulk user invite file was processed, 84 invites mailed with 2 error(s).

Here’s the log:

[2020-12-09 21:34:42 +0000] Invalid Email 'Nxxxx@lisg.ae
[2020-12-09 21:34:43 +0000] Invalid Email 'sxxx@stemk12.org