Php 无法在Ubuntu上安装PEAR邮件

Php 无法在Ubuntu上安装PEAR邮件,php,email,pear,Php,Email,Pear,我不知道以前是否有人经历过这种情况。我试图安装PEAR邮件,以便使用外部服务器发送电子邮件。但当我输入以下命令时,会不断收到错误消息: :~# pear install Mail Mail_Mime 以下是错误消息: Warning: mkdir(): File exists in System.php on line 277 PHP Warning: mkdir(): File exists in /usr/share/php/System.php on line 277 Warning

我不知道以前是否有人经历过这种情况。我试图安装PEAR邮件,以便使用外部服务器发送电子邮件。但当我输入以下命令时,会不断收到错误消息:

:~# pear install Mail Mail_Mime
以下是错误消息:

Warning: mkdir(): File exists in System.php on line 277
PHP Warning:  mkdir(): File exists in /usr/share/php/System.php on line 277

Warning: mkdir(): Not a directory in System.php on line 277
PHP Warning:  mkdir(): Not a directory in /usr/share/php/System.php on line 277
Did not download optional dependencies: pear/Net_SMTP, use --alldeps to download automatically
pear/Mail can optionally use package "pear/Net_SMTP" (version >= 1.4.1)

Warning: mkdir(): File exists in System.php on line 277
PHP Warning:  mkdir(): File exists in /usr/share/php/System.php on line 277

Warning: mkdir(): Not a directory in System.php on line 277
PHP Warning:  mkdir(): Not a directory in /usr/share/php/System.php on line 277
download directory "/build/buildd/php5-5.3.2/pear-build-download" is not writeable.  Change download_dir config variable to a writeable dir
Error: cannot download "pear/Mail"

Warning: mkdir(): File exists in System.php on line 277
PHP Warning:  mkdir(): File exists in /usr/share/php/System.php on line 277

Warning: mkdir(): Not a directory in System.php on line 277
PHP Warning:  mkdir(): Not a directory in /usr/share/php/System.php on line 277
download directory "/build/buildd/php5-5.3.2/pear-build-download" is not writeable.  Change download_dir config variable to a writeable dir
Error: cannot download "pear/Mail_Mime"
Download failed
install failed
我做错什么了吗?我正在Ubuntu上工作

<?php

  require_once "Mail.php";

 $from = "Sandra Sender <info@me.org>";
 $to = "Ramona Recipient <some@somedomain.com>";
 $subject = "Hi!";
 $body = "Hi,\n\nHow are you?";

 $host = "ssl://xxx.xxx.xxx";
 $port = "465";
 $username = "me@domain.org";
 $password = "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>");
  } 
 ?>

您似乎将下载目录设置为/build/buildd/php5-5.3.2/pear-build-download,该目录不可写入

因此,您需要使用chmod使其可写:

# chmod -R 777 /build/buildd/php5-5.3.2/pear-build-download
甚至可能pear配置中的设置是系统早期版本的遗留设置,因此您可能需要重新创建该目录结构,然后执行chmod:

# mkdir -p /build/buildd/php5-5.3.2/pear-build-download

试试PEAR给你的提示:
——alldeps
。所以
pear安装--alldeps Mail-Mail\u Mime
谢谢Samuel,它仍然会溢出错误消息。更新您的帖子并用--alldeps call显示消息谢谢。我已经切换到PHPMailer,它更易于安装和使用。
# mkdir -p /build/buildd/php5-5.3.2/pear-build-download