There is no email validation for outgoing invitations (I think--maybe there is and it's just not working for me). This may not seem like a big deal for the core functionality of Invitations, but it becomes a problem when it interfaces with Userpoints. Users can send invitations to hundreds of non-existent email addresses at a time and receive thousands of Userpoints for doing so. This is especially problematic if Userpoints is used with eCommerce (not the case in my site, but a big issue nonetheless).
I think the best solution would be to call functions from a module like Email Verify (if the user has installed that module) since the validation ability already exists and would not have to be rewritten.
Comments
Comment #1
wotstheguts commentedI've had a go at modifying invite.module as follows by taking code from Email Verify as suggested by IceCreamYou. (Have included functions to handle checkdnsrr and getmxrr functions on a Windows platform).
Disclaimer - I am but a newbie, and I don't know if this is the best way to do it. It works, but is a bit slow if users are permitted to enter a list of email addresses. Let me know what you think.
First, modify the invite_form_validate() function in invite.module:
Then borrow this code from Email Verify module and add to the end of invite.module:
Comment #2
icecreamyou commentedThat won't work if the Email Verify module is installed. This error will be thrown:
I haven't tried it, but everything *should* work if
email_verify_check()is renamed toinvite_email_verify_check().Thanks for looking into this.
Comment #3
wotstheguts commentedHiya, yes I don't have the Email Verify module installed, so that's why I copied the function to invite.module.
If it's already installed, you don't need to duplicate the email_verify_check function in invite.module as you can just call it from invite.module - then only the first block of code needs to be changed.
Comment #4
icecreamyou commentedAlright, I tried it. Renaming email_verify_check works (obviously you have to do it in both places) but the rules set allow things like asdfjaokwejl@aol.com to get through--anything at a valid domain/host.
EDIT: oh, didn't see your last post. Okay.
Comment #5
wotstheguts commentedYou're right. It doesn't allow random Hotmail addresses, but when I tried a random AOL it allowed it through.
I saw that it logged this message in the watchdog:
Type email_verify
Date Sunday, 20 April, 2008 - 11:01
Message Could not verify email address at host aol.com: 220- authorize the use of its proprietary computers and computer
Looking at the code, if it gets any response other than a 250 or 421 it just logs it and exits the function. But AOL returned a 220 response.
If you telnet to port 25 on one of the AOL MX records you get this:
220-rly-ya06.mx.aol.com ESMTP mail_relay_in-ya6.3; Fri, 20 Jan 2006 22:15:42 -05 00
220-America Online (AOL) and its affiliated companies do not
220- authorize the use of its proprietary computers and computer
220- networks to accept, transmit, or distribute unsolicited bulk
220- e-mail sent from the internet. Effective immediately: AOL
220- may no longer accept connections from IP addresses which
220 have no reverse-DNS (PTR record) assigned.
So it looks like the problem might be that AOL sends a whole bunch of 220 messages instead of just one, so the code is putting the wrong info into the $to and $from variables. I'll dig into it a bit more and look at how it could be fixed.
Cheers,
Pete.
Comment #6
wotstheguts commentedHey IceCreamYou,
On another website I found some excellent code to check email address validity. It may be worth using this instead of the Email Verify code, but will need to do some testing first:
https://svn.ampache.org/trunk/modules/validatemail/validateEmail.php
In the meantime, I borrowed a loop from it to check for multiple 220 instances, so it now works for AOL addresses. It still seems to allow yahoo.com addresses through though - for some reason the yahoo mail servers return a 250 "OK" message when you enter any old email address, not sure why. Will check it out.
Updated email_verify_check() function below.
Comment #7
icecreamyou commentedThat's excellent. Thanks for looking into this.
I kind of feel like this should be a separate Email Verify issue and not a continuation of this Invite issue though. Both are equally important and valid, but they're not the same thing and it's just as important that this code get into Email Verify.
Comment #8
wotstheguts commentedYes I agree, the code needs to be looked at in detail and added to the Email Verify issue.
For now, I've noticed that the code is rejecting email addresses that are "greylisted" by some email servers - this just means that the server hasn't seen the sender before, and is expecting the email to be resent after a short delay. Need to change the if statement in the code to allow 450 responses:
Comment #9
ckngCleaning out old issues.