我是亚马逊EC2的新手。 我正试图在我的亚马逊服务器上安装php-pear。 但我得到了一些像下面的错误 enter image description here如何安装php-pear到AWS EC2
有人可以帮助我吗?
我是亚马逊EC2的新手。 我正试图在我的亚马逊服务器上安装php-pear。 但我得到了一些像下面的错误 enter image description here如何安装php-pear到AWS EC2
有人可以帮助我吗?
假设你已经安装了PHP,你可以按照下面的步骤
sudo -i
wget http://pear.php.net/go-pear.phar php go-pear.phar
pear install Mail pear install Net_SMTP
的安装将要求upda打开php.ini文件。请这样做。
我只是今天早些时候安装了它在我的EC2 Linux实例运行PHP7如下:
sudo yum install php7-pear
一旦安装:
pear install Mail
pear install Net_SMTP
但是这不是后一块蛋糕。我遇到了与PHP7和Postfix相关的SMTP设置相关的其他挑战,这给我的具体情况带来了一些困难,因为我想发送base64编码图像内联,这显然是一个非常不寻常的情况,因为我找不到任何帮助它。但是,对于发送简单电子邮件,您只需要以下代码:
require_once "Mail.php";
$from = "My Name <[email protected]>";
$host = "smtp.example.com";
$port = "587";
$username = "[email protected]";
$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>");
}
选中此链接http://jafty.com/blog/installing-pear-on-amazon-ec2-or-ubuntu- linux-server/ – istaro
谢谢,它适用于我 – Lin