【发布时间】:2018-09-04 16:30:42
【问题描述】:
我是 UNIX 的新手,来自 Windows 背景。 我在 Amazon EC2 上创建了一个实例并安装了 apache、PHP 和 MySQl。 我已经成功上传了 PHP 网站的文件。 一切正常,除了我从联系表单发送邮件时遇到问题。
我在这里浏览了 AWS 教程:https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-using-smtp-php.html
我成功安装composer并在Putty中运行它,我看到供应商目录已创建并下载了phpmailer文件。
网站结构如下:
html
test_mail.php
--vendor
----bin
----composer
----phpmailer
----autoload.php
我尝试使用教程中包含的示例电子邮件脚本,它看起来像这样:
// If necessary, modify the path in the require statement below to refer to the
// location of your Composer autoload.php file.
require 'vendor/autoload.php';
use PHPMailer\PHPMailer\PHPMailer;
// Instantiate a new PHPMailer
$mail = new PHPMailer;
// Tell PHPMailer to use SMTP
$mail->isSMTP();
$mail->SMTPDebug = 2;
// Replace sender@example.com with your "From" address.
// This address must be verified with Amazon SES.
$mail->setFrom('sender@example.com', 'Sender Name');
但我收到以下错误:
Fatal error: Uncaught Error: Class 'PHPMailer\PHPMailer\PHPMailer' not found in /var/www/testSite/html/test_mail.php:10 Stack trace: #0 {main} thrown in /var/www/testSite/html/test_mail.php on line 10
第 10 行是
$mail = new PHPMailer;
所以我不知道问题是什么。 所需的 PHPMailer 文件似乎已由 composer 正确创建,并且 'vendor\autoload.php' 的路径应该是正确的。
我错过了服务器设置中的某些内容吗?
任何建议都非常感谢。
大卫
【问题讨论】:
-
问题已发布,请阅读此内容。 stackoverflow.com/questions/28906487/…
-
奇怪,它建议
~5.2但该版本不使用自动加载器:/ 安装最新版本的 phpmailer 应该没问题(6.0)
标签: php amazon-web-services amazon-ec2 phpmailer