sandy1028 Posted August 13, 2007 Share Posted August 13, 2007 Hi, I have a submit query page. I receive mails from invalid email id. How to confirm whether the users email id is valid. Receive the mails from users only when the email id is valid or not receive the mails from invalid email id... How can I check the email Please help me with this Quote Link to comment https://forums.phpfreaks.com/topic/64634-submit-query/ Share on other sites More sharing options...
Wuhtzu Posted August 13, 2007 Share Posted August 13, 2007 What is an email id? Quote Link to comment https://forums.phpfreaks.com/topic/64634-submit-query/#findComment-322232 Share on other sites More sharing options...
sandy1028 Posted August 13, 2007 Author Share Posted August 13, 2007 It is email address of the users.... How can I confirm the email address of the users without sending the mail back to the users email address Quote Link to comment https://forums.phpfreaks.com/topic/64634-submit-query/#findComment-322237 Share on other sites More sharing options...
MadTechie Posted August 13, 2007 Share Posted August 13, 2007 View the header, ie MIME-Version: 1.0 Received: from server.######.com ([64.####.####.197]) by bay0-mc7-f11.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2668); Sat, 11 Aug 2007 01:23:22 -0700 Received: from ###.#######.net ([209.###.###.34])by server.######.com with esmtpa (Exim 4.67 (FreeBSD))(envelope-from <REAL@DOMAIN.com>)id 1IJmEo-0007Md-BZfor r#######@hotmail.com; Sat, 11 Aug 2007 08:22:22 +0000 X-Message-Delivery: Vj0zLjQuMDt1cz##2k9MDtsPTA7YT0w X-Message-Info: 6sSXyD95QpU8d/9lfRH5Aptnba##MGrqt1ZEPdUCYU6Hd+4ZLrT9PbaxeFYdmNvSRTFdXjLysBiPWr0S8uSg== X-Mailer: PHPMailer [version 1.73] X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - #############.com X-AntiAbuse: Original Domain - hotmail.com X-AntiAbuse: Originator/Caller UID/GID - [26 6] / [26 6] X-AntiAbuse: Sender Address Domain - #########.com X-Source: X-Source-Args: X-Source-Dir: Return-Path: webmaster@########.com X-OriginalArrivalTime: 11 Aug 2007 08:23:22.0241 (UTC) FILETIME=[E154BF10:01C7DBF0] i removed some details Quote Link to comment https://forums.phpfreaks.com/topic/64634-submit-query/#findComment-322241 Share on other sites More sharing options...
Wuhtzu Posted August 13, 2007 Share Posted August 13, 2007 You can not check whether or not an e-mail address exists without sending an e-mail to the e-mail address. All you can do is check the syntax / format of the e-mail address. <?php if(preg_match("/^([a-z0-9]+)([a-z0-9_-]*)([a-z0-9]+)@([a-z0-9]+)([a-z0-9-]*)([a-z0-9]+)\.([a-z]{1-3})/i")) { echo "Valid syntax"; } else { echo "Invalid syntax"; } ?> The above regex check whether or not the e-mail looks like email@address.com *Maybe I have misunderstood what you are trying to do Quote Link to comment https://forums.phpfreaks.com/topic/64634-submit-query/#findComment-322246 Share on other sites More sharing options...
MadTechie Posted August 13, 2007 Share Posted August 13, 2007 that RegEx won't work try if (preg_match('/^\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b$/si', $email)) { echo "valid"; } or fix the Wuhtzus one change ([a-z]{1-3}) to ([a-z]{1,3}) but the Wuhtzu's one will fail on a few ie metest@hotmail.coop me.test@hotmail.com or metest@nothing.com hello Quote Link to comment https://forums.phpfreaks.com/topic/64634-submit-query/#findComment-322251 Share on other sites More sharing options...
Wuhtzu Posted August 13, 2007 Share Posted August 13, 2007 Sorry aobut the {1-3} it should of course be {1,3} but I do not agree with you on the e-mail addresses which will fail validation... My regex, if there is no more mis-typings, will check that the e-mail's local part starts and ends with a-z or 0-9, in between it can hold _ and - which is not allowed to occur at the start or end according to the standards. After that it check for almost the same thing with the domain, that it stats and ends with a-z or 0-9 and may hold a - (minus) in between but again not start or end with - according to domain name standards. Of course you could (and maybe should) allow more signs like . (dot) + (plus) and % to be in between the start and end of the local part. And of course ([a-z]{1,3}) is the quick tld check - to be accurate you have to check against an array of all current tlds Quote Link to comment https://forums.phpfreaks.com/topic/64634-submit-query/#findComment-322255 Share on other sites More sharing options...
sandy1028 Posted August 13, 2007 Author Share Posted August 13, 2007 I am not validating the email address whether it is in format of abc@xyz.com I want to check whether email address of the person exists or not. The page which other users can use is submit query page where they can send the comments. Quote Link to comment https://forums.phpfreaks.com/topic/64634-submit-query/#findComment-322256 Share on other sites More sharing options...
Wuhtzu Posted August 13, 2007 Share Posted August 13, 2007 The only way of finding out whether or not an e-mail address exists is to send an e-mail and receive some kind of confirmation - e.g. they have to click a link or something. Quote Link to comment https://forums.phpfreaks.com/topic/64634-submit-query/#findComment-322258 Share on other sites More sharing options...
MadTechie Posted August 13, 2007 Share Posted August 13, 2007 but i could always enter bill.gates@microsoft.com thats a valid email but he may not of posted.. without sending an email and getting a reply i don't see how you can do this, side note: heres a nice email validator <?php function isValidAddress( $email, $check = false ) { if (!ereg('' . '^' . '[-!#$%&\'*+/0-9=?A-Z^_a-z{|}~]' . '(\\.?[-!#$%&\'*+/0-9=?A-Z^_a-z{|}~])*' . '@' . '[a-zA-Z](-?[a-zA-Z0-9])*' . '(\\.[a-zA-Z](-?[a-zA-Z0-9])*)+' . '$' , $email ) ) return false; list( $local, $domain ) = split( "@", $email, 2 ); if ( strlen($local) > 64 || strlen($domain) > 255 ) return false; if ( $check && !gethostbynamel( $domain ) ) return false; return true; } ?> @Wuhtzu, this is what you should use as will fail on a few check the examples i posted "^[a-z0-9_\+-]+(\.[a-z0-9_\+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.([a-z]{2,4})$"; Quote Link to comment https://forums.phpfreaks.com/topic/64634-submit-query/#findComment-322259 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.