Chat Posted October 3, 2008 Share Posted October 3, 2008 hi, i'm trying to make a script to validate email addresses. i start with: <?getmxrr('birminghampr.co.uk',$mxhosts); then i try: $x=system("telnet $mxhosts[0] 25", $y); ...and 3 lines are printed: Trying 64.233.183.27... Connected to ASPMX.L.GOOGLE.COM. Escape character is '^]'. while $x becomes the last line generated by the system... Escape character is '^]'. ...while $y becomes the number "1" to say something like it was a good command.... but if i try to manually "telnet aspmx.l.google.com 25" i get an additional response banner as the 4th line: 220 mx.google.com ESMTP i4si16*********.1 ...now what i need to do is somehow grab this 4th line using PHP! any ideas anyone? any help would be very much appreciated. Link to comment https://forums.phpfreaks.com/topic/126910-recording-response-from/ Share on other sites More sharing options...
corbin Posted October 5, 2008 Share Posted October 5, 2008 Instead of using a system call, do the connection making inside of PHP. http://php.net/fsockopen or http://php.net/socket_create if you feel like doing it the long way Link to comment https://forums.phpfreaks.com/topic/126910-recording-response-from/#findComment-657642 Share on other sites More sharing options...
Chat Posted October 5, 2008 Author Share Posted October 5, 2008 hi corbin, thanks for the reply. i normally use file_get_contents and file_put_contents, sometimes curl, and sometimes file()... but i've never used these socket functions before is there any chance you could give me some example code of how to a "telnet aspmx.l.google.com 25" and record the response? Link to comment https://forums.phpfreaks.com/topic/126910-recording-response-from/#findComment-657690 Share on other sites More sharing options...
corbin Posted October 5, 2008 Share Posted October 5, 2008 <?php $sock = fsockopen("aspmx.l.google.com", 25, $errno, $errstr, (float) 0.5); if($sock) { $line1 = fgets($sock); } else { echo "Unable to connect to host."; } Link to comment https://forums.phpfreaks.com/topic/126910-recording-response-from/#findComment-657727 Share on other sites More sharing options...
Chat Posted November 7, 2008 Author Share Posted November 7, 2008 thanks corbin, you're a genius, it works just as i needed Link to comment https://forums.phpfreaks.com/topic/126910-recording-response-from/#findComment-684513 Share on other sites More sharing options...
corbin Posted November 7, 2008 Share Posted November 7, 2008 No problem. Glad it worked. Link to comment https://forums.phpfreaks.com/topic/126910-recording-response-from/#findComment-684930 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.