用PearMail发邮件
时间:2021-07-01 10:21:17
帮助过:31人阅读
<无详细内容>
- 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 = 'https://www.gxlcms.com/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','https://www.gxlcms.com/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';
- }
- ?>
|