Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services SMTP服务器错误:需要身份验证_Amazon Web Services_Email_Amazon Ec2_Phpmailer - Fatal编程技术网

Amazon web services SMTP服务器错误:需要身份验证

Amazon web services SMTP服务器错误:需要身份验证,amazon-web-services,email,amazon-ec2,phpmailer,Amazon Web Services,Email,Amazon Ec2,Phpmailer,我是AmazonEC2实例的新实例。现在我想使用php代码向客户端发送邮件。我在我的AmazonEC2实例中安装了wamp并运行这些文件 <?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require 'src/PHPMailer.php'; require 'src/SMTP.php'; //SMTP Settings $mail

我是AmazonEC2实例的新实例。现在我想使用php代码向客户端发送邮件。我在我的AmazonEC2实例中安装了wamp并运行这些文件

 <?php
        use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;


require 'src/PHPMailer.php';
require 'src/SMTP.php';

        //SMTP Settings
        $mail = new PHPMailer();
        $mail->IsSMTP();
        $mail->SMTPAuth   = true; 
        $mail->SMTPSecure = "tls"; 
        $mail->Host       = "email-smtp.us-east-1.amazonaws.com";
        $mail->Port = 25;
        $mail->Username   = "support@example.com";
        $mail->Password   = "*******";
        //

        $mail->SetFrom('support@example.com', 'Example'); //from (verified email address)
        $mail->Subject = "Email Subject"; //subject

        //message
        $body = "This is a test message.";
        $body = eregi_replace("[\]",'',$body);
        $mail->MsgHTML($body);
        //

        //recipient
        $mail->AddAddress("myname@gmail.com", "Myname"); 

        //Success
        if ($mail->Send()) { 
            echo "Message sent!"; die; 
        }

        //Error
        if(!$mail->Send()) { 
            echo "Mailer Error: " . $mail->ErrorInfo; 
        } 

        ?>

当运行这些文件时,我遇到了一些错误

解析错误:第304行的C:\wamp\www\samplemail\src\PHPMailer.php中出现解析错误


您使用的是非常旧版本的PHPMailer,并且您的代码基于一个过时的示例,所以。设置
$mail->SMTPDebug=2
并向我们显示结果,以便了解服务器不喜欢您的原因。原因可能有多种:1)您是否确认端口和安全组已被阻止。2) 您也可以尝试使用AWSSES@Synchro我升级了phpmailer。。现在我升级了我的问题,但是我仍然得到了错误,解析错误意味着你正在运行一个非常旧的PHP版本-也升级它。我使用的是PHP版本8.0