-
error_reporting(E_ALL);
-
- require 'Mail.php';
- require 'Mail/mime.php';
-
- $text = "Text version of email\nMessage made with PHP";
- $html = 'HTML version of email
';
- $html .= 'Message made with ';
- $crlf = "\n";
-
- $from = 'from_address@163.com';
- $to = 'to_address@qq.com';
- $password = '123456';
-
- $mail_config=array(
- "host"=>"smtp.163.com",
- "port"=>25,
- "auth"=>true,
- "username"=>$from,
- "password"=>$password,
- "from"=>$from,
- );
-
- $hdrs = array(
- 'From'=>$from,
- 'Subject'=>'Test HTMl Email with Embedded Image'
- );
- $mime = new Mail_mime($crlf);
- $mime->setTXTBody($text);
- $mime->addHTMLImage('php.gif','image/gif','12345',true);
- $mime->setHTMLBody($html);
- $body = $mime->get();
- $hdrs = $mime->headers($hdrs);
-
- $mail = Mail::factory('smtp',$mail_config);
- $succ = $mail->send($to,$hdrs,$body);
-
- if (PEAR::isError($succ))
- {
- echo 'Email sending failed: ' . $succ->getMessage();
- }
- else
- {
- echo 'Email sent succesfully';
- }
- ?>
-
复制代码
|