Home > php教程 > PHP源码 > body text

PHP使用pear_smtp发送简单邮件

PHP中文网
Release: 2016-05-22 17:22:28
Original
1317 people have browsed it

PHP使用pear_smtp发送简单邮件

<?php  
 require_once "vendor/autoload.php";  
   
 $from = "test<test@163.com>";  
 $to = "test <test@outlook.com>";  
 $subject = "Hi!";  
 $body = "Hi,\n\nHow are you?";  
   
 $host = "smtp.163.com";  
$port = "25"; 
 $username = "test@163.com";  
 $password = "test123";  
   
 $headers = array (&#39;From&#39; => $from,  
   &#39;To&#39; => $to,  
   &#39;Subject&#39; => $subject);  
 $smtp = Mail::factory(&#39;smtp&#39;,  
   array (&#39;host&#39; => $host,  
     &#39;port&#39; => $port,  
     &#39;auth&#39; => true, 
    // &#39;debug&#39;=>true, 
     &#39;username&#39; => $username,  
     &#39;password&#39; => $password));  
   
 $mail = $smtp->send($to, $headers, $body);  
   
 if (PEAR::isError($mail)) {  
   echo("<p>" . $mail->getMessage() . "</p>");  
  } else {  
   echo("<p>Message successfully sent!</p>");  
  }  
 ?>
Copy after login

                   

 以上就是PHP使用pear_smtp发送简单邮件的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!