2016-08-01 9 views
-5

を送っていない私の問題は、私は、ユーザーに電子メールを送信するためのコード私はHerokuのサーバでそれを押したときに動作していないローカルホストでの私のためにいくつかのボタンでクリックして、その作品が、PHPコード:Eメール

<?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 = '[email protected]'; 
    $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('[email protected]', '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 

答えて

0

あなたを持っていますホスティングプロバイダはスパミングにシステムが使用されないように電子メールを無効にしている可能性があります。彼らがあなたのためにそれを有効にするかどうかを確認するためにそれらに連絡する必要があります。

そうでない場合は、サードパーティサービスの使用を検討することをおすすめします。

+0

あなたの答えをありがとうが、私はherokuサーバーで2つのアプリケーションをphpメーラーで最初に動作し、ユーザーに電子メールを送信しますが、2番目のアプリケーションは送信できません。 ? –

+0

と私はlocalhostの作業でテストしたとき! –

関連する問題