电子邮件未发送。无法实例化邮件功能

时间:2019-04-09 04:15:24

标签: php

  

有什么解决办法吗   我正在使用最新版本的php

这是我的testing_mail.php文件

 

这是我的send_mail文件

<?php

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'vendor/autoload.php';

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

function sendemailses($email,$subject,$key)
{
    $mail = new PHPMailer(true);           // Passing `true` enables exceptions
    try {

        $mail = new PHPMailer;


       // $mail->isSMTP();


        $mail->setFrom('info@bloodcheck.co.in', 'E-Leave System');


        $mail->addAddress($email, 'Recipient Name');


        $mail->Username = '';


        $mail->Password = '';


        $mail->Host = 'email-smtp.us-east-1.amazonaws.com';



        $mail->Subject = 'Testing mail for Bloodcheck! ';

        $mail->SMTPAuth = true;
        $mail->SMTPDebug = 0;
        $mail->SMTPSecure = 'tls';
        $mail->Port = 587;

        $mail->isHTML(true);
        $message ="<h1>Testing Mail";

        $mail->Body = $message;

        $mail->AltBody = "Email Test\r\nThis email was sent through the 
    Amazon SES SMTP interface using the PHPMailer class.";
        if (!$mail->send()) {
            echo "Email not sent. ", $mail->ErrorInfo, PHP_EOL;
        }
    } catch (Exception $e) {
        echo '<br>';
        var_dump($e->getMessage());
        echo '<br>';
        echo 'Message could not be sent. Mailer Error: ', $mail-ErrorInfo;
    }
}
?>

我收到一个错误:

  

电子邮件未发送。无法实例化邮件功能。   有什么解决办法吗   我正在使用最新版本的php

0 个答案:

没有答案