PHP Perl - mail/mime.php 无法打开流

Ena*_*lds 0 php php-5.5

我需要一些帮助,如何使用 Perl 发送电子邮件。

当我尝试运行此代码时:

require_once ("Mail.php");
require_once ("Mail/mime.php");

$text = "test";
$html_message = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>....</title>
</head>
<body>
    <p>...</p>
</body>
</html>';

$headers["From"] = 'sample@sampel.com';
$headers["To"] = "sample@sampel.com"; 
$headers["Subject"] = "Sample SMTP PERL";
$headers["Content-Type"] = 'text/html; charset=UTF-8';
$headers["Content-Transfer-Encoding"]= "8bit";

$mime = new Mail_mime; 
$mime->setTXTBody($text); 
$mime->setHTMLBody($html_message); 
$mimeparams=array(); 

// It refused to change to UTF-8 even if the header was set to this, after adding the following lines it worked.

$mimeparams['text_encoding']="8bit"; 
$mimeparams['text_charset']="UTF-8"; 
$mimeparams['html_charset']="UTF-8"; 
$mimeparams['head_charset']="UTF-8"; 

$mimeparams["debug"] = "True"; 

$body = $mime->get($mimeparams); 
$headers = $mime->headers($headers); 
$page_content = "Mail now."; 

// SMTP server name, port, user/passwd 
$smtpinfo["host"] = "xxx;
$smtpinfo["port"] = "465";
$smtpinfo["auth"] = true;
$smtpinfo["username"] = "sample@sample.com";
$smtpinfo["password"] = "xxx";
$smtpinfo["debug"] = "True"; 


// Create the mail object using the Mail::factory method
$mail=& Mail::factory("smtp", $smtpinfo);

$mail->send($to, $headers, $body));
Run Code Online (Sandbox Code Playgroud)

我收到此错误消息:

PHP Warning:  require_once(Mail/mime.php): failed to open stream: No
such file or directory in /home3/xxx/public_html/xxx/zzz/ccc/vvv.php
on line 203 

PHP Fatal error:  require_once(): Failed opening required
'Mail/mime.php'

(include_path='.:/usr/php/54/usr/lib64:/usr/php/54/usr/share/pear:/usr/lib/php/PEAR')
in /home3/xxx/public_html/xxx/zzz/ccc/vvv.php on line 203
Run Code Online (Sandbox Code Playgroud)

我不知道如何解决这个问题。请帮忙。

Mat*_*son 6

确保您已经安装了所需的 PEAR 包。

Mail.php 是“Mail”的一部分,但 mime.php 是“Mail_Mime”的一部分。

pear install Mail Mail_Mime
Run Code Online (Sandbox Code Playgroud)