Email conversation
From | Henrik Fosgerau |
To | Me |
Subject | Email validation with PHP |
Date | 11 February 2004 15:23 |
Hello
I have been testing your Email address validator at
http://www.howtocreate.co.uk/php/
Some email addresses fail the validation but work quite normal using an
ordinary email client.
Have you got any idea why they fail or what the errors mean to me?
Is there a workaround to bypass the errors if they are harmless?
Cheers!
Henrik Fosgerau
Here are some of the error messages:
[3 examples showing debugging output from my validateEmail script]
From | Me |
To | Henrik Fosgerau |
Subject | Re: Email validation with PHP |
Date | 11 February 2004 17:06 |
ok, I thought I had fixed it, but I hadn't. Please give me a while. I know
what is wrong. Your email server is somewhat unique and sends two
connection response headers. I will try to deal with it.
As for the third problem, that is much more easy to fix. I will try and
update the script asap.
Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
From | Me |
To | Henrik Fosgerau |
Subject | Re: Email validation with PHP |
Date | 11 February 2004 17:47 |
Sorry, don't mean to bombard you with emails, but this one I think is
important to you.
The third example demonstrates a problem with your email server(s)
For email.address@hidden.from.you.dk there are two email servers:
server1.hidden.from.you.dk, server2.hidden.from.you.net
Unfortunately, the second one of these: 'server2.hidden.from.you.net'
refuses to accept email to to that email address from any email address,
yours, mine or <> (the null sender).
I have even tried talking directly to the server over SMTP through telnet,
and I still couldn't get it to accept anything.
I am still working on a way to avoid problems with the first two examples,
as they should have worked, but a bug in my script prevents them from
showing as valid.
From | Me |
To | Henrik Fosgerau |
Subject | Re: Email validation with PHP |
Date | 11 February 2004 19:45 |
Ok, it took me a few hours, but I realised at last how to fix it so it
always works with the first two examples. I had missed that each 220 was
followed by a '-', so I keep going until it serves a 2\d\d\s ;)
in other words, it works properly now. I have uploaded an updated version.
Thanks. I couldn't do this without the eagle-eyed vigilance of visitors
like you.
cheers
Mark 'Tarquin' Wilton-Jones
From | Henrik Fosgerau |
To | Me |
Subject | Re: Email validation with PHP |
Date | 12 February 2004 08:21 |
Hi Mark
I'm very pleased that you solved the problems so quickly.
And I forgot to tell you that I think your script is very useful and I like
it a lot :-)
Unfortunately there still seems to be a problem with some servers.
I have two examples concerning the domains de-bergske.dk and
djurslandsposten.dk
After a little testing, I discovered, that the MX records don't resolve in
the same way for every query.
The mailserver addresses aren't returned in the same order.
For instance, if the returned servers for 'hiddenDomain.dk' are returned like
this: 'firstServer.dk, secondServer.net' - it works. But if it looks like
this: 'secondServer.net, firstServer.dk' - it doesn't work.
I don't know if there is a way to compensate for this, but I thought you
would like to know.
Henrik Fosgerau
Here are the complete messages:
[Two more debugging examples, showing secondary mail servers failing to
accept email addresses, even though the primary ones did]
From | Me |
To | Henrik Fosgerau |
Subject | Re: Email validation with PHP |
Date | 12 February 2004 08:40 |
This behaviour is correct. MX records are returned in random order by the
servers in order to spread the load across the servers. They are also
weighted, but for something as simple as this script, there is no need to
use weightings. Besides which, this script checks each server in turn until
one is available. If one server is misconfigured (as is true with both
examples you sent me), that server may prevent relaying.
I am planning to add weightings in a future release (maybe even later today,
as I have the day off ... :) to avoid fallback servers that are
misconfigured, as is the case with both of these examples.
From | Me |
To | Henrik Fosgerau |
Subject | Re: Email validation with PHP |
Date | 12 February 2004 09:29 |
:)
I said I would update it today .. and I did, because it was only a simple
change.
The function now takes weightings into account. If you try those email
addresses that failed before, you will see that they always work because
the servers have weightings 10 and 20. The servers that have weighting 20
do not allow relaying because they are misconfigured. This is because the
person that set them up is being lazy, and not updating them when they
update the others. They assume that the fallback server is never needed.
This defies the purpose of having fallback servers, so if they can't be
bothered to set them up correctly, they might as well get rid of them. That
way, retry mail will go to a server that actually works instead of a server
that says all email addresses are invalid!
From | Henrik Fosgerau |
To | Me |
Subject | Re: Email validation with PHP |
Date | 12 February 2004 10:59 |
Hi Mark
Thanks again. It looks like you've got it tuned to match various conditions.
I have tested the script with a list of 98 different email addresses on
newspapers in Denmark.
Right now there are two addresses which take a very long time to process.
And sometimes they fail.
The worked fine earlier today and yesterday.
Do you think it's just a temporary problem with these two servers at the
moment - or could something in your script be causing this?
Henrik Fosgerau
The addresses:
[more debugging info]
From | Me |
To | Henrik Fosgerau |
Subject | Re: Email validation with PHP |
Date | 12 February 2004 11:20 |
The second example is just a server being VERY slow! But it did actually
work. The server is probably just very busy.
The first example shows a problem with the server. The script timed out
waiting for the server to respond to the rcpt to command. I tried this
myself using telnet on port 25. The server still failed to respond. I think
you would be lucky to get it to accept emails at the moment.. Even when it
does reply, it just denies relaying. Hopefully, the server administrator
will fix the server eventually, but at the moment, you will not be able to
send emails to that email address, so the script correctly says that the
email address is not currently valid.