我是Amazon EC2的新手。
我正在尝试在我的Amazon服务器上安装php-pear。
但是我遇到了以下错误:
点击此处查看图片
有人能帮帮我吗?
我今天早些时候在运行PHP7的EC2 Linux实例上安装了它,方法如下:
sudo yum install php7-pear
pear install Mail
pear install Net_SMTP
require_once "Mail.php";
$from = "My Name <no-reply@example.com>";
$host = "smtp.example.com";
$port = "587";
$username = "user@example.com";
$password = "password";
$subject = "Some subject";
$headers = array('From' => $from, 'To' => $to, 'Subject' => $subject);
$body = "\r\n\r\n--" . $boundary . "\r\n";
$body .= "Content-type: text/plain; charset=\"iso-8859-1\"\r\n";
$body .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$body .= "This is the message body.";
$body .= "\r\n\r\n--" . $boundary . "\r\n";
$smtp = Mail::factory('smtp', array(
'debug' => true,
'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>");
}
假设您已经安装了PHP,您可以按照以下步骤进行操作
sudo -i
wget http://pear.php.net/go-pear.phar
php go-pear.phar
pear install Mail
pear install Net_SMTP
安装程序会要求更新php.ini文件。请完成这一步骤。