第5月第15天 php email

1.

<?php  
 require_once "Mail.php";  
   
 $from = "luckyeggs<fuping304@163.com>";  
 $to = "cheking<fuping304@163.com>";  
 //$to = "cheking<394276418@qq.com>";  
 $subject = "hello!";  
 $body = "12312";  
 
  /*********ʹÓÃÒÔÏÂÃû³ÆsslЭÒé·¢ËÍ***********/
 //$host = "ssl://smtp.163.com";  
 //$port = "465";
 
 
 /*********ʹÓÃÒÔÏÂÃû³Æ·ÇsslЭÒé·¢ËÍ***********/
 $host = "smtp.163.com";  
 $port = "25";  
 $username = "fuping304";  
 $password = "";  
   
 $headers = array ('From' => $from,  
   'To' => $to,  
   'Subject' => $subject);  
 $smtp = @Mail::factory('smtp',  
   array ('host' => $host,  
     'port' => $port,  
     'auth' => true,  
     'username' => $username,  
     'password' => $password));  
   
 $mail = @$smtp->send($to, $headers, $body);  
   
 if (@PEAR::isError($mail)) {  
   echo("<p>" . $mail->getMessage() . "</p>");  
  } else {
   echo("<p>Message successfully sent!</p>");
  }  
 ?> 

 

2.httprequest down

 

$target = "aa.txt";
$url = "http://www.baidu.com/";

require_once 'installer/HTTPClient.inc';
$c = new HTTPClient();
$req = new HTTPRequest();
$req->setURL($url);
// if ($from !== null)
//     $req->downloadRange($from, $to);
$responses = $c->send($req);
$resp = $responses[count($responses)-1];
if ($resp->getStatus() < 200 || $resp->getStatus() >= 300)
    throw new Exception("Error downloading file, server response: ".$resp->getStatus()." ".$resp->getStatusMessage());
if ($target == null) return $resp->getBody();
$f = fopen($target,"a");
fwrite($f,$resp->getBody());
fclose($f);


die("OK");

 

https://github.com/passerellesnumeriques/Students-Database/tree/7a7ce9f76670d166413a4a96999d9e3b8b58ead0

posted @ 2017-02-15 13:46  lianhuaren  阅读(145)  评论(0编辑  收藏  举报