Validation of email addresses is a huge subject of Discussion.
This is an interesting essai about the email filter quality and variants:
http://www.regular-expressions.info/email.html
Due to the variety of answers to this simple questions we should leave some decisions to the user which way to go.
We should collect here additional references to good discussions or papers and then think about a clean futureproof solution. Possibly for the next drupal core too.
In my opinion we should:
- Check for standard validation (which already is subject of many discussions how to check...)
- Optionally trigger additional modules to check address if available.
Custom modules even should have the possibility to allow mails which originally failed checking.
Core provides:
http://api.drupal.org/api/function/valid_email_address
From a sending recursion issue #780132: Mail/Send error leads to infinite loop and cron crash we have the suggested mail validation project:
http://drupal.org/project/email_verify
^^ which is currently abandoned and not updated for a year. There are critical issues!
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | simplenews_948894_simplenews_valid_email_2.patch | 589 bytes | Markus Winand |
| #5 | simplenews_948894_simplenews_valid_email.patch | 4.98 KB | simon georges |
| #3 | simplenews-emailverify.patch | 592 bytes | jmrivero |
Comments
Comment #1
jmrivero commentedOk, here goes the first stone, Email Verify integration first try.
In simplenews.subscription.inc, line 168.
From this:
To this:
Comment #2
miro_dietikerLet's think about adding a custom function to implement the whole emailcheck variant - e.g. simplenews_email_verify(). It would implement the switch and add reusability of the code.
Your code is a great start but it only addresses one single case in simplenews.
We need to consider all other sn form cases where email addresses could be entered. Please check and complete. That's also why i thought about the API to check and reuse the API instead of copying the validation code.
BTW: How about providing a clean patch against DRUPAL-6--2 as an attachment? We should avoid adding too much code in the issue itself and it would allow me to apply your changes without any manual work.
Thanks!
Comment #3
jmrivero commentedSN is using valid_email_address function for all email validations right?
if that is the case it wont be hard to create a simplenews_email_verify function and change all valid_email_address calls for the new one.
Where do you think that simplenews_email_verify should be implemented, simplenews.module?
#1 code patch attached ( my first patch so please verify file encoding and sintax).
Comment #4
miro_dietikerI did a quick search in the code and find:
All occurrences need to be checked for extension coverage.
Comment #5
simon georges commentedHi,
I'm providing a patch containing :
- simplenews_valid_email_address() function, containing in fact the patch similar to the one in #3
- replace every call to core valid_email_address() function by a call to this one
Best regards,
Comment #6
miro_dietikerReviewed and committed to dev.
Now it's much more simple to even add more extended mail format checker or even add a hook.
Comment #8
Markus Winand commentedIt seems like the previous patch has a little glitch.
The
simplenews_valid_email_addressexpects true/false whileemail_verifyreturns null/error-msg.Minimalistic patch attached.
Comment #9
miro_dietikerWhen checking email_verify, i even see
http://drupalcode.org/project/email_verify.git/blob_plain/refs/heads/6.x...
While i'm strongly against this API definition - it should still provide a full check API, we need to check for this additionally in simplenews_valid_email_address().
Else, we'll always accept generally wrong formatted mails.
Comment #10
bensey commentedHi there,
not sure where I should be reporting this, but in a search for this issue, this was the closest and most relevant result I found.
This is not a 2.x-dev issue either but I can't find any reference anywhere to it being fixed in 2.x. I'm running 6.x-1.3.
Anyway, I manage a rather busy site that receives quite a lot of new subscriptions, and I'm constantly finding sending errors to addresses ending in a full-stop eg. "me@mydomain.com."
Could this be added to Simplenews' validation, or should it maybe be added to core (or is it already), or could they be slipping through from my client's use of 'mass subscribe'?
Comment #11
miro_dietikerMass subscribes should also be validated like public subscriptions. Are we missing it currently?
We don't want to validate custom rules. This should happen via a clean/separate validation module.
If our current implementation is not enough, we should add a email validation hook you could implement in a custom module...
However such a feature should also be provided by drupal core registration email check. So we'll try to follow core as tight as possible.
Comment #12
rmcom commentedFor some, the patch in this comment may provide a solution.
http://drupal.org/node/1291774#comment-5957960 (patch waiting to be ported).