所以,我正在制作一个脚本来发送一封没有发送到垃圾邮件文件夹的电子邮件,因此我使用的是smtp身份验证,但问题是我无法让它工作,我已经下载了梨文件和设置为包括,但仍然没有工作,我收到这些错误,任何人有任何想法如何解决这个问题?
警告:include_once(Net / SMTP.php):无法打开流:365行/home2/anfisool/public_html/maquinasdeoutrostempos.com/lab2/login/php/Mail/smtp.php中没有此类文件或目录
警告:include_once():无法打开&#39; Net / SMTP.php&#39;在第365行的/home2/anfisool/public_html/maquinasdeoutrostempos.com/lab2/login/php/Mail/smtp.php中包含(include_path =&#39;。:/ opt / php71 / lib / php&#39;)< / p>
致命错误:未捕获错误:类&#39; Net_SMTP&#39;找不到/home2/anfisool/public_html/maquinasdeoutrostempos.com/lab2/login/php/Mail/smtp.php:366堆栈跟踪:#0 /home2/anfisool/public_html/maquinasdeoutrostempos.com/lab2/login/php/Mail /smtp.php(271):Mail_smtp-&gt; getSMTPObject()#1 /home2/anfisool/public_html/maquinasdeoutrostempos.com/lab2/login/php/Mail/smtp.php(258):Mail_smtp-&gt; send_or_fail(& #39; henriquemmceles ...&#39;,数组,&#39;嗨,\ n \ n你好...&#39;)#2 /home2/anfisool/public_html/maquinasdeoutrostempos.com/lab2/login /php/register_front_php.php(145):Mail_smtp-&gt;发送(&#39; henriquemmceles ......&#39;,数组,&#39;嗨,\ n \ n你好...&#39; )#3 /home2/anfisool/public_html/maquinasdeoutrostempos.com/lab2/login/register_front.php(3):include(&#39; / home2 / anfisool ...&#39;)#4 {main}引入第366行/home2/anfisool/public_html/maquinasdeoutrostempos.com/lab2/login/php/Mail/smtp.php
First image, Inside the Mail folder
在这种情况下,由于显而易见的原因,变量$ from,$ host,$ username和$ password中的内容也会受到审查,但我确信证书是正确的。
require_once "Mail.php";
$to = $_SESSION['email'];
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$from = "***************";
$host = "***********";
$username = "******************";
$password = "******";
$headers = array ('From' => $from,'To' => $to, 'Subject' => $subject);
$smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("" . $mail->getMessage() . "");
} else {
echo("Message successfully sent!");
}