phpMailer停止发送电子邮件

时间:2019-09-09 20:08:06

标签: php email phpmailer

因此,此确切的代码以前曾发送过电子邮件。我已将其上传到以前的目录中。

我没有收到任何PHP代码错误,也没有将任何内容添加到error_log中,因此使我相信这一定是服务器问题,并且我可能会丢失一些代码。但是对我来说,它看起来还不错,没有错误,并且自从上次在服务器上以来就没有更改过。

<?php

    use PHPMailer\PHPMailer\PHPMailer;

    if(isset($_POST['submit'])) 
    {
        // Values need to be santiised

        $forename = $_POST['forename'];
        $surname = $_POST['surname'];
        $email = $_POST['email'];
        $phone = $_POST['phone'];
        $service = $_POST['service'];
        $date = $_POST['date'];
        $time = $_POST['time'];

        $timestamp =date('l jS \of F Y h:i:s A');

        $text = "".$forename.",".$surname.",".$email.",".$phone.",".$service.",".$date.",".$time.",".$timestamp." \n";
        $file = fopen("./data/requests.csv","a+ \n");
        fwrite($file, $text);
        fclose($file);

        require '../vendor/autoload.php';

        $mail = new PHPMailer;
        $mail->isSMTP();
        $mail->SMTPDebug = 0;
        $mail->Host = 'smtp.hostinger.com';
        $mail->Port = 587;
        $mail->SMTPAuth = true;
        $mail->Username = 'noreply@handler.net';
        $mail->Password = 'password';
        $mail->SMTPSecure = 'tls';

        $mail->setFrom('noreply@handler.net','Bookings | Email'); // Emails sent via noreply.

        $mail->addAddress('bookings@salon.com','Bookings'); // Email form responses sent to bookings@salon.com

        $mail->addReplyTo($email,$forename.' '.$surname); // Reply to the user who submitted the form.

        $mail->addBCC('outbox@handler.net',''); // Store record of all emails sent via the system in outbox@handler.net

        $mail->Subject = 'Booking Request from '.$forename.' '.$surname.' '; // Subject of the email sent to bookings@salon.com that the form responses will be contained within.

        $mail->isHTML(TRUE);
        $mail->Body = <<<EOD


           <!-- Email contents goes here -->

EOD;
        if(!$mail->send()) { // Send the email.
          echo '';
          echo 'Mailer error: ' . $mail->ErrorInfo;
        } else {
          echo '';
        }
    }
    ?>

我不太确定现在该尝试什么方法。如果有任何代码错误,我将不胜感激,因为我已经对其进行了一些评论或提供了指导,并且除了服务器端之外,无法弄清楚问题是什么。

任何帮助将不胜感激。

0 个答案:

没有答案