【发布时间】:2020-06-28 12:41:22
【问题描述】:
我收到 警告错误:require_once(Composer/PHPMailer/vendor/phpmailer/phpmailer/src/autoload.php):无法打开流:/home/hyperspace/public_html/ 中没有此类文件或目录第 5 行的contact.php 和致命错误:require_once(): Failed opening required 'Composer/PHPMailer/vendor/phpmailer/phpmailer/src/autoload.php' (include_path='.:/opt/ alt/php72/usr/share/pear') 在第 5 行的 /home/hyperspace/public_html/contact.php 中,我没有对我的 cpanel 的 root 访问权限。您可以在http://hyperspacedesigns.co.za/contact.php 检查错误。我使用的代码是:
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require_once "Composer/PHPMailer/vendor/phpmailer/phpmailer/src/autoload.php"; //This is line 5//
$mail = new PHPmailer();
$mail->Host = "";
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->Username = "";
$mail->Password = "";
$mail->SMTPSecure = "ssl";
$mail->Port = 465;
$mail->addAddress('contact@hyperspacedesigns.co.za');
$mail->setFrom($_POST['email']);
$mail->name = $_POST['name'];
$mail->Subject = $_POST['subject'];
$mail->number = $_POST['number'];
$mail->isHTML(true);
$mail->Body = $_POST['message'];
if ($mail->send())
$msg = "Your email has been sent, Thank You!";
else
//$msg = "Please try agian!";
echo $mail->ErrorInfo;
?>
我的 html 在我的表单所在的 contact.php 文件中,这是我的表单代码:
<!-- /contact-form -->
<section class="w3l-contact-main">
<div class="contact-infhny py-5">
<div class="container">
<div class="contact-grids row py-lg-5">
<div class="contact-left col-lg-6">
<img src="assets/images/contact-sec.jpg" alt="" class="img-fluid">
</div>
<div class="contact-right col-lg-6 pl-lg-4">
<h3>Contact</h3>
<h4>Everything Starts With A Hello!</h4>
<p>We’re here to answer any questions you may have and create an effective solution for your instructional needs.</p>
<?php if ($msg != "") echo "$msg<br>"; ?>
<form action="contact.php" method="post" class="signin-form mt-lg-5 mt-4">
<div class="input-grids">
<input type="text" name="name" placeholder="Full name" class="contact-input" />
<input type="email" name="email" placeholder="Your email" class="contact-input" />
<input type="text" name="subject" placeholder="Subject" class="contact-input" />
<input type="number" name="number" placeholder="Phone number" class="contact-input" />
</div>
<div class="form-input">
<textarea name="message" placeholder="Type your message here" required=""></textarea>
</div>
<div class="form-input mb-5">
<label class="container"><p>Send me a copy <a href="#">privacy policy.</a></p>
<input type="checkbox">
<span class="checkmark"></span>
</label>
</div>
<button class="btn submit">Submit</button>
</form>
</div>
</div>
</div>
</div>
<div class="map-hny">
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d387193.305935303!2d-74.25986548248684!3d40.69714941932609!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x89c24fa5d33f083b%3A0xc80b8f06e177fe62!2sNew+York%2C+NY%2C+USA!5e0!3m2!1sen!2sin!4v1563262564932!5m2!1sen!2sin" style="border:0" allowfullscreen=""></iframe>
</div>
</section>
<!-- //contact-form -->
我知道它不会发送电子邮件,因为我没有更改我的提交按钮以使用 php,但我在加载页面时收到错误。
我使用 composer 来安装 PHPMailer。在我的 Composer 文件中,我安装了 PHPMailer 及其所有组件。我没有更改 php.ini 中的任何内容,因为我不知道它是否与我的错误有关。我不知道这是否与我没有 root 访问权限有关。有人可以帮帮我吗?
【问题讨论】:
标签: php composer-php phpmailer