note 65528 added to function.getmxrr

From: Date: Tue, 02 May 2006 20:38:58 +0000
Subject: note 65528 added to function.getmxrr
Groups: php.notes 
Request: Send a blank email to php-notes+get-110393@lists.php.net to get a copy of this message
It seems that everybody complains about the fact that Windows does not have a getmxrr() function. I am not sure that this is really the case(Microsoft has an old habit of not publicly documenting some of Windows's functions). So, try this : $con=fsockopen('smtp.' .$hostname); It works on all versions of Windows, including 9x, but sometimes it fails - I don't know why ,but I think that the quality of the results depends on the quality of the DNS server that your ISP provides you. Since a getmxrr function is usually needed for writing a mailing function, and nobody is providing such a function, I am giving you a basic one here : function mymail($to,$from,$exp,$subj,$mesaj) { //***************************************** //Mail function created by Liviu Macoviciuc , liviumacoviciuc2000@yahoo.com //Use this function however you like ,but please keep the comment //***************************************** $mes=explode("\r\n",$mesaj); $to=trim($to); $temp=explode("@",$to); //Linux version //$a=getmxrr($temp[1],$host); //if($a){$server=$host[0];} //else{$server=$temp[1];} //$con=fsockopen($server,25,$erno,$erstr); $con=fsockopen('smtp.'.$temp[1],25,$erno,$erstr); if(!$con){file_put_contents("raport.txt","$erno $erstr $to\r\n",FILE_APPEND); } else{$read=fgets($con); echo($read); //$loc=$_SERVER['SERVER_NAME']; fputs($con,"EHLO as.ro\r\n"); do{$read=fgets($con); echo($read); if(strpos($read,"-")===FALSE){break;}; }while(!feof($con)); fputs($con,"MAIL FROM:<".$from.">\r\n"); $read=fgets($con); echo($read); fputs($con,"RCPT TO:<".$to.">\r\n"); $read=fgets($con); echo($read); fputs($con,"DATA\r\n"); $read=fgets($con); echo($read); fputs($con,"MIME-Version:1.0\r\n"); fputs($con,"Date:".date("r")."\r\n"); fputs($con,"Subject:".$subj."\r\n"); fputs($con,"From:".$exp."\r\n"); fputs($con,"Reply-to:".$from."\r\n"); fputs($con,"To:".$to."\r\n"); fputs($con,"Content-Type:text/html\r\n"); fputs($con,"\r\n"); for($i=0;$i<count($mes);$i++){ fputs($con,"$mes[$i]\r\n"); } fputs($con,"\r\n.\r\n"); $read=fgets($con); echo($read); fputs($con,"QUIT\r\n"); $read=fgets($con); echo($read); fclose($con); } } Example of usage : mymail('anunt@as.ro', 'liviumacoviciuc2000@yahoo.com', "Liviu Macoviciuc", 'C.V. - curriculum vitae', "<html>..</html>"); ---- Server IP: 66.163.161.117 Probable Submitter: 86.124.138.128 (proxied: 172.18.9.18) ---- X-Spam-Status: No, hits=3.8 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER, HTML_MESSAGE,MAILTO_TO_SPAM_ADDR autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.getmxrr.php Edit -- http://master.php.net/note/edit/65528 Del: integrated -- http://master.php.net/note/delete/65528/integrated Del: useless -- http://master.php.net/note/delete/65528/useless Del: bad code -- http://master.php.net/note/delete/65528/bad+code Del: spam -- http://master.php.net/note/delete/65528/spam Del: non-english -- http://master.php.net/note/delete/65528/non-english Del: in docs -- http://master.php.net/note/delete/65528/in+docs Del: other reasons-- http://master.php.net/note/delete/65528 Reject -- http://master.php.net/note/reject/65528 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#110393) next »