PHPMailer无法解析

时间:2018-06-27 15:36:46

标签: php phpmailer

因此,我试图在我创建的网站上建立“联系我们”页面,但PHPMailer只是拒绝为我工作。

据我所知,它根本无法识别PHPMailer类,我不确定为什么。据我所知,这是我发送电子邮件的表单的PHP代码,据我所知,我已经正确安装了PHPMailer / Composer,并且已正确完成了其他所有操作,但是尝试使用PHPMailer时仍然出现错误。 “ PHPMailer无法解析为类型”和“导入PHPMailer \ PHPMailer \ PHPMailer无法解析”

    <?php   
                    use PHPMailer\PHPMailer\PHPMailer;
                    require_once './vendor/autoload.php';

                    // Bunch of code validating all the variables from the form

                    function send_mail($toEmail, $endSubject, $endMessage, $endName) {                                                  
                        $mail = new PHPMailer(true);

                        $mail->isSMTP();
                        $mail->Host = "smtp.domain.com";
                        $mail->SMTPAuth = true;
                        $mail->Username = "LOGIN EMAIL"; // Email
                        $mail->Password = "PASSWORD"; // Email password
                        $mail->SMTPSecure = "tls";
                        $mail->Port = "587";

                        $mail->From = "example@domain.com"; //RANDOM EMAIL TO SEND THESE MESSAGES TO OUR EMAIL
                        $mail->FromName = $endName; //CUSTOMERS NAME

                        $mail->addAddress($toEmail); //WHOEVER WE ARE SENDING THESE EMAILS TO

                        $mail->isHTML(true);

                        $uri = 'http://'. $_SERVER['HTTP_HOST'];
                        $mail->Subject = $endSubject;
                        $mail->Body = $endMessage;

                        if($mail->send()) {
                            return true;
                        } else {
                            return false;
                        }
                    }
                    ?>

0 个答案:

没有答案