12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?
- //email ("lord_rimmon@mail.ru", "ggg", "lol");
- function get_data($smtp_conn)
- {
- $data="";
- while($str = fgets($smtp_conn,515))
- {
- $data .= $str;
- if(substr($str,3,1) == " ") { break; }
- }
- return $data;
- }
- function email($to, $subj, $text)
- {
- $smtp = "pvlt.ru";
- $name = "Dark Matter";
- $send_mail = "info@dmatter.net";
- $send_host = "dmatter.net";
- $smtp_user = "info@dmatter.net";
- $smtp_pass = "Death12";
-
-
- $header="Date: ".date("D, j M Y G:i:s")." +0700\r\n";
- $header.="From: =?windows-1251?Q?".str_replace("+","_",str_replace("%","=",urlencode($name)))."?= <".$send_mail.">\r\n";
- $header.="X-Mailer: The Bat! (v3.99.3) Professional\r\n";
- $header.="Reply-To: =?windows-1251?Q?".str_replace("+","_",str_replace("%","=",urlencode($name)))."?= <".$send_mail.">\r\n";
- $header.="X-Priority: 3 (Normal)\r\n";
- $header.="Message-ID: <172562218.".date("YmjHis")."@".$send_host.">\r\n";
- $header.="To: =?windows-1251?Q?".str_replace("+","_",str_replace("%","=",urlencode($to)))."?= <".$to.">\r\n"; //to name
- $header.="Subject: =?windows-1251?Q?".str_replace("+","_",str_replace("%","=",urlencode($subj)))."?=\r\n";
- $header.="MIME-Version: 1.0\r\n";
- $header.="Content-Type: text/plain; charset=windows-1251\r\n";
- $header.="Content-Transfer-Encoding: 8bit\r\n";
-
- $smtp_conn = fsockopen($smtp, 25,$errno, $errstr, 10);
- if(!$smtp_conn) {print "ñîåäèíåíèå ñ ñåðâåðîì íå ïðîøëî "; fclose($smtp_conn); return false; exit;}
- $data = get_data($smtp_conn);
- fputs($smtp_conn,"EHLO ".$smtp."\r\n");
- $code = substr(get_data($smtp_conn),0,3);
- if($code != 250) {print "îøèáêà ïðèâåòñâèÿ EHLO"; fclose($smtp_conn); return false; exit;}
- fputs($smtp_conn,"AUTH LOGIN\r\n");
- $code = substr(get_data($smtp_conn),0,3);
- if($code != 334) {print "ñåðâåð íå ðàçðåøèë íà÷àòü àâòîðèçàöèþ "; fclose($smtp_conn); return false; exit;}
-
- fputs($smtp_conn,base64_encode($smtp_user)."\r\n");
- $code = substr(get_data($smtp_conn),0,3);
- if($code != 334) {print "îøèáêà äîñòóïà ê òàêîìó þçåðó "; fclose($smtp_conn); return false; exit;}
-
-
- fputs($smtp_conn,base64_encode($smtp_pass)."\r\n");
- $code = substr(get_data($smtp_conn),0,3);
- if($code != 235) {print "íåïðàâèëüíûé ïàðîëü "; fclose($smtp_conn); return false; exit;}
-
- fputs($smtp_conn,"MAIL FROM:".$send_mail."\r\n");
- $code = substr(get_data($smtp_conn),0,3);
- if($code != 250) {print "ñåðâåð îòêàçàë â êîìàíäå MAIL FROM "; fclose($smtp_conn); return false; exit;}
-
- fputs($smtp_conn,"RCPT TO:".$to."\r\n");
- $code = substr(get_data($smtp_conn),0,3);
- if($code != 250 AND $code != 251) {print "Ñåðâåð íå ïðèíÿë êîìàíäó RCPT TO "; fclose($smtp_conn); return false; exit;}
-
- fputs($smtp_conn,"DATA\r\n");
- $code = substr(get_data($smtp_conn),0,3);
- if($code != 354) {print "ñåðâåð íå ïðèíÿë DATA "; fclose($smtp_conn); return false; exit;}
-
- fputs($smtp_conn,$header."\r\n".$text."\r\n.\r\n");
- $code = substr(get_data($smtp_conn),0,3);
- if($code != 250) {print "îøèáêà îòïðàâêè ïèñüìà "; fclose($smtp_conn); return false; exit;}
-
- fputs($smtp_conn,"QUIT\r\n");
- fclose($smtp_conn);
- return true;
- }
- ?>
|