猿问

AWS elasticbeanstalk 上 PHPMailer 实施的故障排除建议

在 AWS elasticbeanstalk 上部署一段代码,向用户发送电子邮件验证帐户创建。我测试了电子邮件代码,它可以在我的本地机器上运行。为了在服务器上测试它,我编写了这个测试用例并且它有效。但是当它被应该使用它的模块调用时,它就会中断。我需要故障排除方面的帮助。

由于同一个模块被 2 个不同的模块(test 和 prod)调用,并且它与 test 一起工作,我倾向于认为它与调用模块有关,但除了 include 语句的格式之外,我没有看到它会如何破裂。

工作测试代码:

试验结果:

http://img2.mukewang.com/638ab77f0001fdc006050103.jpg

错误:


[Wed Apr 01 16:45:53.262139 2020] [php7:notice] [pid 10670] [client 136.55.180.140:29275] Array\n(\n    [count] => 1\n)\n, referer: http://bluetooth-env-test.eba-brqgvwur.us-east-2.elasticbeanstalk.com/WebApp/new_user.php

[Wed Apr 01 16:47:40.599465 2020] [php7:warn] [pid 10669] [client 136.55.180.140:29293] PHP Warning:  require_once(../PHPMailer/PHPMailer.php): failed to open stream: No such file or directory in /var/app/current/WebApp/utils/emailVerification.php on line 13, referer: http://bluetooth-env-test.eba-brqgvwur.us-east-2.elasticbeanstalk.com/WebApp/new_user.php

[Wed Apr 01 16:47:40.599502 2020] [php7:error] [pid 10669] [client 136.55.180.140:29293] PHP Fatal error:  require_once(): Failed opening required '../PHPMailer/PHPMailer.php' (include_path='.:/usr/share/pear7:/usr/share/php') in /var/app/current/WebApp/utils/emailVerification.php on line 13, referer: http://bluetooth-env-test.eba-brqgvwur.us-east-2.elasticbeanstalk.com/WebApp/new_user.php

共享模块的源代码:它在 require_once('../PHPMailer/PHPMailer.php'); 处中断


<?php


// session_start();


    use PHPMailer\PHPMailer\PHPMailer;

    use PHPMailer\PHPMailer\SMTP;

    use PHPMailer\PHPMailer\Exception;


function emailVerify($email, $hash){




require_once('../PHPMailer/PHPMailer.php');

require_once('../PHPMailer/SMTP.php');

require_once('../PHPMailer/Exception.php');



echo (extension_loaded('openssl')?'SSL loaded':'SSL not loaded')."\n";


$mail = new PHPMailer(true);


try{

$mail->SMTPDebug = SMTP::DEBUG_SERVER;

$mail->SMTPOptions = array(

                  'ssl' => array(

                      'verify_peer' => false,

                      'verify_peer_name' => false,

                      'allow_self_signed' => true

                  )

              );

慕标琳琳
浏览 128回答 1
1回答

泛舟湖上清波郎朗

根据 Synchro 的输入,有效的解决方案是:&nbsp; &nbsp; require_once( __DIR__.'/../PHPMailer/PHPMailer.php');&nbsp; &nbsp; require_once( __DIR__.'/../PHPMailer/SMTP.php');&nbsp; &nbsp; require_once( __DIR__.'/../PHPMailer/Exception.php');
随时随地看视频慕课网APP
我要回答