Topic: User created with invalid email when Verify registrations is on

I recently changed the signup options on my board by changing the "Verify registrations" to yes.  Now, when I test using an email address which is not valid, I get the following error:

Error: Unable to send e-mail. Please contact the forum administrator with the following error message reported by the SMTP server: "550 5.1.1  User unknown; rejecting ".

The user account is still created despite rejecting the address.

FYI I did a search through the forums but didn't find a workaround / fix to this possible issue.

rgds

Si

Re: User created with invalid email when Verify registrations is on

keldar wrote:

I recently changed the signup options on my board by changing the "Verify registrations" to yes.  Now, when I test using an email address which is not valid, I get the following error:

Error: Unable to send e-mail. Please contact the forum administrator with the following error message reported by the SMTP server: "550 5.1.1  User unknown; rejecting ".

The user account is still created despite rejecting the address.

FYI I did a search through the forums but didn't find a workaround / fix to this possible issue.

rgds

Si

I might be wrong here (don't think I am though), but that's the way it's supposed to work. The user account will be created no matter if it's a valid e-mail or not, but the user won't be able to use that account until logging in with the password supplied in the e-mail...

Re: User created with invalid email when Verify registrations is on

keldar wrote:
CodeXP wrote:

I might be wrong here (don't think I am though), but that's the way it's supposed to work. The user account will be created no matter if it's a valid e-mail or not, but the user won't be able to use that account until logging in with the password supplied in the e-mail...

I can see where your coming from on this, but I fail to see the reason that someone can sign up with a duff address.  If they want to hide that address then its quite simple for them to do so.

TBH I added the "verify registrations" as some muppet kept signing in with duff emails, literally creating dozens of accounts. 

If this is not a bug, then perhaps a feature request could be made to only accept valid emails (optionally of course smile).

rgds

Si

Re: User created with invalid email when Verify registrations is on

Thinking about it a little further, I have the "verify registrations" options turned on, if an email can not be sent, especially as in the case of my error "User Unknown" then it will never verify, and shouldn't really create the account  or at the very least delete it afterwards.

I havn't dug too much into the code, but the parts of the code I read in register.php never used any sort of caching mechanism so as it could resend the email at a later time, if it fails initially.  That being said, my PHP scripting abilities are minimal smile

Re: User created with invalid email when Verify registrations is on

keldar wrote:

Thinking about it a little further, I have the "verify registrations" options turned on, if an email can not be sent, especially as in the case of my error "User Unknown" then it will never verify, and shouldn't really create the account  or at the very least delete it afterwards.

What if the email server is  temporarily down for some reason?

Re: User created with invalid email when Verify registrations is on

to send it again they can just press forgotten password, but the registration simply returns the SMTP server error message it doesn't think about it.

Re: User created with invalid email when Verify registrations is on

Just so we're clear. "User unknown; rejecting" is the error from your mail server. You've simply supplied the wrong information.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

8 (edited by keldar 2005-09-07 21:33)

Re: User created with invalid email when Verify registrations is on

Rickard wrote:

Just so we're clear. "User unknown; rejecting" is the error from your mail server. You've simply supplied the wrong information.

No, my original message included the error code returned by the smtp server, the code is 550.  If you look here the description for err code 550 is "Requested action not taken: mailbox unavailable." i.e. User unknown.

PHP, like I said is not my forté, however looking at the code in email.php you have a function smtp_mail, this method frequently makes calls to another function "server_parse" looking for a response code, if the expected response code is not found it raises an exception, e.g.

    if (!(substr($server_response, 0, 3) == $expected_response))
        error('Unable to send e-mail. Please contact the forum administrator with the following error message reported by the SMTP server: "'.$server_response.'"', __FILE__, __LINE__);

Which is the adzact error I have been receiving.

if you expand the code in smtp_mail function, from:

    fwrite($socket, 'Subject: '.$subject."\r\n".$to_header."\r\n".$headers."\r\n\r\n".$message."\r\n");

    fwrite($socket, '.'."\r\n");
    server_parse($socket, '250');

you could add an extra check to see if the email account it is trying to send to is valid, prior to checking for ok message, something like:

    fwrite($socket, 'Subject: '.$subject."\r\n".$to_header."\r\n".$headers."\r\n\r\n".$message."\r\n");

        if (IsValidEmailAddress($socket))
        {
           // email address is invalid, can't send email
           return (false);        
        }

    fwrite($socket, '.'."\r\n");
    server_parse($socket, '250');

this would require a new function to check if email address is valid, something like:

function IsValidEmailAddress($socket)
{
    $server_response = '';
    while (substr($server_response, 3, 1) != ' ')
    {
        if (!($server_response = fgets($socket, 256)))
            error('Couldn\'t get mail server response codes. Please contact the forum administrator.', __FILE__, __LINE__);
    }

    return(!(substr($server_response, 0, 3) == '550');
}

I am not trying to be awkward, honestly smile, I thought I was reporting a genuine bug, which is:

when "verify registrations" is on, and the email address is obviously invalid (returns err code 550), then the account which has been created will never be able to be verified and should be deleted. 

This might help eliminate bogus sign-ups, which I, and others (like in this post) have been receiving lately.

btw, I have not tried compiling/running the above script.

kind regards

Si

Re: User created with invalid email when Verify registrations is on

keldar wrote:
Rickard wrote:

Just so we're clear. "User unknown; rejecting" is the error from your mail server. You've simply supplied the wrong information.

No, my original message included the error code returned by the smtp server, the code is 550.  If you look here the description for err code 550 is "Requested action not taken: mailbox unavailable." i.e. User unknown.

yes the user which is unknown is the user you are trying to send mail through, i.e. you are connecting to the smtp server with an unknown account AKA mailbox

10

Re: User created with invalid email when Verify registrations is on

The problem is, there is absolutely no bullet-proof way to check if a e-mail address is valid until after sending a mail. Sure, you could check if the server responds, but the problem is (as mentioned), what if it was temporarily unavailable? Also, a check like you suggested keldar wouldn't really help, other than to verify the existence of the domain.
There are other, better ways to do it (google it), but by using those, you'd exclude a whole bunch of valid servers as well.