views:

18036

answers:

15

I have come across this PHP code to check email address using SMTP without sending an email.

Has anyone tried anything similar or does it work for you? Can you tell if an email customer / user enters is correct & exists? Thanks!

+1  A: 

Not really.....Some server may not check the "rcpt to:"

http://www.freesoft.org/CIE/RFC/1123/92.htm

Doing so is security risk.....

If the server do, you can write a bot to discovery every address on the server....

l_39217_l
+3  A: 

The general answer is that you can not check if an email address exists event if you send an email to it: it could just go into a black hole.

That being said the method described there is quite effective. It is used in production code in ZoneCheck except that it uses RSET instead of QUIT.

Where user interaction with his mailbox is not overcostly many sites actually test that the mail arrive somewhere by sending a secret number that must be sent back to the emitter (either by going to a secret URL or sending back this secret number by email). Most mailing lists work like that.

kmkaplan
+4  A: 

Some issues:

  1. I'm sure some SMTP servers will let you know immediately if an address you give them does not exist, but some won't as a privacy measure. They'll just accept whatever addresses you give them and silently ignore the ones that don't exist.
  2. As the article says, if you do this too often with some servers, they will blacklist you.
  3. For some SMTP servers (like gmail), you need to use SSL in order to do anything. This is only true when using gmail's SMTP server to send email.
Graeme Perrow
Regarding the third point, this only happen if you want to use it as a relay. I do not know of any mail exchanger that requires SSL. If any did this they would stop receiving email from many users.
kmkaplan
Sorry, my mistake. If you want to *send* email using gmail's SMTP server, you must use SSL.
Graeme Perrow
A: 

Hi,

I've made an newsletter application in the past and I had the same problem. In general there isn't really a way to check this. We tried to overcome the problem by a real good regex that checked the email address. And with an tracking system. If an email was bounced 3 times the email address was removed from the list. I hope this helps out a bit.

Regards, Sem

Sem Dendoncker
+1  A: 

"Can you tell if an email customer / user enters is correct & exists?"

Actually these are two separate things. It might exist but might not be correct.

Sometimes you have to take the user inputs at the face value. There are many ways to defeat the system otherwise.

Learning
+1 You can _never_ be sure that it is correct without sending an email and actually getting a human response for it, such as clicking a link.
Daniel Daranas
A: 

Assuming it's the user's address, some mail servers do allow the SMTP VRFY command to actually verify the email address against its mailboxes. Most of the major site won't give you much information; the gmail response is "if you try to mail it, we'll try to deliver it" or something clever like that.

Austin Salonen
A: 

I think you cannot, there are so many scenarios where even sending an e-mail can fail. Eg. mail server on the user side is temporarily down, mailbox exists but is full so message cannot be delivered, etc.

That's probably why so many sites validate a registration after the user confirmed they have received the confirmation e-mail.

PhiLho
A: 

About all you can do is search DNS and ensure the domain that is in the email address has an MX record, other than that there is no reliable way of dealing with this.

Some servers may work with the rcpt-to method where you talk to the SMTP server, but it depends entirely on the configuration of the server. Another issue may be an overloaded server may return a 550 code saying user is unknown, but this is a temporary error, there is a permanent error (451 i think?) that can be returned. This depends entirely on the configuration of the server.

I personally would check for the DNS MX record, then send an email verification if the MX record exists.

Redbeard 0x0A
A: 

no serious SMTP server will give you out what addresses exist. this would just allow spammers to find out what address exist.

dusoft
+10  A: 

There are two methods you can sometimes use to determine if a recipient actually exists:

  1. You can connect to the server, and issue a VRFY command. Very few servers support this command, but it is intended for exactly this. If the server responds with a 2.0.0 DSN, the user exists.

    VRFY user

  2. You can issue a RCPT, and see if the mail is rejected.

    MAIL FROM:<>

    RCPT TO:<user@domain>

If the user doesn't exist, you'll get a 5.1.1 DSN. However, just because the email is not rejected, does not mean the user exists. Some server will silently discard requests like this to prevent enumeration of their users. Other servers cannot verify the user, and have to accept the message regardless.

Joseph Tary
A: 

I always check if MX records are available/visible via this website: http://my-addr.com/check-email-or-check-find-view-domain-mx-records/mx-record-lookup/domain_mx.php

Dennis van der Stelt
A: 

maybe a good solution ? here

marc-andre menard
A: 

See Validate an Email Address Via SMTP using php which has both domain and email user verification.

NeoCambell
A: 

There's a trick that can check email address with mail server that not support email verification. The trick is you can connect directly to the web mail to check email exist (just for free email service) ;) The demo is: Verify Email Address. It can check Yahoo email address

Anh Do
A: 

--- validate email whether existed or not

gopinadh