Body: <p>I have a problem that occurs occasionally but not reproducibly.</p>
  
  <p>There are cases where donors visit the on-line contribution page to make a donation, enter their details and click Next, and get a validation error "Email is not valid". The vast majority of donors have no problem.</p>
  
  <p>This is not reproducible on my test system.</p>
  
  <p>The check is done by HTML_QuickForm_Rule_Email::validate() which checks the address matches a regex and optionally does a DNS lookup. As far as I can tell, the DNS lookup option is never used, so the only check is against the regex.</p>
  
  <p>Any thoughts as to why this might occasionally fail? It doesn't make sense it fails but can't be reproduced.</p>
  
  <p>Production is running PHP 5.5.9 and test is 5.6.11.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-17T01:27:24.963Z
Comments.Text: Do the donors see the field prepopulated when shown the error? Anything in CiviCRM.XXX.log? No pattern (eg non-ascii chars) to the email addresses?
Comments.UserDisplayName: Chris Burgess
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-17T01:28:25.293Z
Comments.Text: If unable to repro, i'd add debug code to the validation function which told me the contents of any email failing validation in the CiviCRM log.
Comments.UserDisplayName: Chris Burgess
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-17T02:13:09.410Z
Comments.Text: Thanks for the idea, Chris. It I log the email address I can also see how prevalent is the issue.
Comments.UserDisplayName: Ken West
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-17T11:29:56.523Z
Comments.Text: Do the donors have e-mail addresses that fail common regexes, but still comply with RFCs?
Comments.UserDisplayName: DaveFF
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-18T22:52:34.963Z
Comments.Text: Dave, I don't know. When I enter the email address of the person, the regex comparison accepts the email address. But perhaps there is user error? I would have thought that most people would (upon seeing the error) correct the email address and try again. I'm taking Chris' advice and adding debug code.
Comments.UserDisplayName: Ken West
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-19T20:27:20.363Z
Comments.Text: Keep us posted :) [CRM-16313](https://issues.civicrm.org/jira/browse/CRM-16313) and [CRM-15975](https://issues.civicrm.org/jira/browse/CRM-15975) are recently submitted issues with validation of emails but symptoms didn't match what Ken describes.
Comments.UserDisplayName: Chris Burgess
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-19T20:28:53.457Z
Comments.Text: Can you repeat the behavior by eg putting a space before or after the email field? Maybe a location type mismatch? Guessing here :)
Comments.UserDisplayName: Chris Burgess
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-20T21:49:53.320Z
Comments.Text: Chris, I can reproduce the behaviour by adding spaces, but I don't know if that is what these users are doing. My model of their behaviour is that they inspect the email address and fix it, but I guess an extra space would go unnoticed.
Comments.UserDisplayName: Ken West
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-20T22:05:23.780Z
Comments.Text: Chris, I guess it would Do No Harm to trim spaces leading and trailing spaces from the email address before validating/processing it
Comments.UserDisplayName: Ken West
Tags: <contribution-page>
Title: Why do occasional donors get message "Email is not valid"
ThreadText: # Why do occasional donors get message "Email is not valid"
  
  (Asked by: username_0 on 2015-12-17)
  
  I have a problem that occurs occasionally but not reproducibly.
  
  There are cases where donors visit the on-line contribution page to make a donation, enter their details and click Next, and get a validation error "Email is not valid". The vast majority of donors have no problem.
  
  This is not reproducible on my test system.
  
  The check is done by HTML\_QuickForm\_Rule\_Email::validate() which checks the address matches a regex and optionally does a DNS lookup. As far as I can tell, the DNS lookup option is never used, so the only check is against the regex.
  
  Any thoughts as to why this might occasionally fail? It doesn't make sense it fails but can't be reproduced.
  
  Production is running PHP 5.5.9 and test is 5.6.11.
  
  **Tags:** contribution-page
  
  > **Comments:**
  > **username_1**: Do the donors see the field prepopulated when shown the error? Anything in CiviCRM.XXX.log? No pattern (eg non-ascii chars) to the email addresses?  
  > **username_1**: If unable to repro, i'd add debug code to the validation function which told me the contents of any email failing validation in the CiviCRM log.  
  > **username_0**: Thanks for the idea, username_1. It I log the email address I can also see how prevalent is the issue.  
  > **username_2**: Do the donors have e-mail addresses that fail common regexes, but still comply with RFCs?  
  > **username_0**: Dave, I don't know. When I enter the email address of the person, the regex comparison accepts the email address. But perhaps there is user error? I would have thought that most people would (upon seeing the error) correct the email address and try again. I'm taking username_1' advice and adding debug code.  
  > **username_1**: Keep us posted :) [CRM-16313](https://issues.civicrm.org/jira/browse/CRM-16313) and [CRM-15975](https://issues.civicrm.org/jira/browse/CRM-15975) are recently submitted issues with validation of emails but symptoms didn't match what Ken describes.  
  > **username_1**: Can you repeat the behavior by eg putting a space before or after the email field? Maybe a location type mismatch? Guessing here :)  
  > **username_0**: username_1, I can reproduce the behaviour by adding spaces, but I don't know if that is what these users are doing. My model of their behaviour is that they inspect the email address and fix it, but I guess an extra space would go unnoticed.  
  > **username_0**: username_1, I guess it would Do No Harm to trim spaces leading and trailing spaces from the email address before validating/processing it  
  
  ---
  
  ## 0 answers
  
  