Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php代码:电子邮件不发送_Php_Email - Fatal编程技术网

php代码:电子邮件不发送

php代码:电子邮件不发送,php,email,Php,Email,我的问题是,当我点击某个按钮时,我有一个向用户发送电子邮件的代码,它在本地主机中对我有效,但在heroku服务器中按下它时不起作用 <?php if (isset($_POST['submitcmt']) && $_POST['token'] == $dcs_user_info['token']) { //get rows in watchlist table if contest_id (job_id)==contest_id in database $watc

我的问题是,当我点击某个按钮时,我有一个向用户发送电子邮件的代码,它在本地主机中对我有效,但在heroku服务器中按下它时不起作用

<?php

if (isset($_POST['submitcmt']) && $_POST['token'] == $dcs_user_info['token']) {
    //get rows in watchlist table if contest_id (job_id)==contest_id in database $watchlist_table = mysqli_query($conn, "SELECT * FROM watchlist WHERE contest_id='$contest_id'") or die("Error: " . mysqli_error($watchlist_table));
}

if (mysqli_num_rows($watchlist_table) > 0) {

    //get rows from content table
    $contentsTable = mysqli_query($conn, "SELECT * FROM contests WHERE id='$contest_id'")
    or die("Error: " . mysqli_error($conn));

    //to can use the rows in users table 
    $row_contents = mysqli_fetch_array($contentsTable, MYSQLI_ASSOC);

    //get rows from users table
    $userTable = mysqli_query($conn, "SELECT * FROM users WHERE id!='" . $dcs_user->user['id'] . "'")
        or die("Error: " . mysqli_error($conn));

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

    $mail = new PHPMailer;
    $mail->IsSMTP();
    $mail->SMTPAuth = true;
    //$mail->SMTPDebug=2;
    //$mail->Debugoutput = 'html';

    $mail->SMTPOptions =
        [
            'ssl' => [
                'verify_peer' => false,
                'verify_peer_name' => false,
                'allow_self_signed' => true,
            ],
        ];

    $mail->Host = 'smtp.gmail.com';
    $mail->Username = 'faresalkhwaja@gmail.com';
    $mail->Password = 'elkhawajah1';
    $mail->SMTPSecure = 'ssl';
    $mail->Port = 465;

    //to select all the email in database
    while ($row_user = mysqli_fetch_array($userTable, MYSQLI_ASSOC)) {

        $mail->From = 'tasqat';
        $mail->FromName = 'tasqat';
        $mail->addReplyTo('faresalkhwaja@gmail.com', 'tasqat');
        $mail->addAddress($row_user['email'], $row_user['email']);

        $mail->Subject = "new comment";

        $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

        $mail->Body = "job title :" . $row_contents['title'] . "<br>" . "user name :" . $row_comment['display_name'] . "<br>" . "date : " . $row_comment['date'] . "<br>" . "comment : " . $row_comment['comment'] . "<br>" . "host : " . $actual_link;

        $mail->AltBody = 'this is body';
    }
}//end while loop

您的主机提供商可能已禁用电子邮件,以防止其系统被用于垃圾邮件。你应该联系他们,看看他们是否会为你启用它


如果他们不想,你可能想考虑使用第三方服务。

谢谢你的回答,但是我有两个应用程序在HeloCu服务器第一个应用程序在PHP梅勒和发送电子邮件给用户,但第二个应用程序不能发送,它几乎相同的代码在第一个应用程序和第二个应用程序…所以???