Advertisement
Matts933

Untitled

Mar 9th, 2019
450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.42 KB | None | 0 0
  1.     <?php
  2. $data = date("d-m-Y H:i:s");
  3. include('database_connection.php');
  4. include('function.php');
  5. require 'class/class.phpmailer.php';
  6. $output = '';
  7. $output1 = '';
  8. $count_prodotti = 0;
  9.     $query = "
  10.     SELECT * FROM product
  11.     ";
  12.     $statement = $connect->prepare($query);
  13.     $statement->execute(
  14.         array(
  15.             )
  16.     );
  17.  
  18.     $result = $statement->fetchAll();
  19.             foreach($result as $row)
  20.     {
  21.        
  22.        
  23.         if($row['product_quantity'] <= $row['prodotto_minimo'])
  24. {
  25.     $count_prodotti = $count_prodotti + 1;
  26.     $output .= '
  27.    <strong>'.$row['product_id'].' '.get_category_nome($connect, $row['category_id']).' - '.get_brand_nome($connect, $row['brand_id']).' - '.get_modello_nome($connect, $row['id_modello']).'</strong><div>'.$row["product_name"].': <strong><font color="red">'.$row["product_quantity"].'</font></strong> Pz</div><span class="date"><em>Prodotto</em>
  28.        
  29. ';
  30.        
  31.         }
  32.        
  33.          
  34.  
  35.     }  
  36.         $mail = new PHPMailer;
  37.         $mail->IsSMTP();                                //Sets Mailer to send message using SMTP
  38.         $mail->Host = 'smtp.gmail.com';     //Sets the SMTP hosts of your Email hosting, this for Godaddy
  39.         $mail->Port = '465';                                //Sets the default SMTP server port
  40.         $mail->SMTPAuth = true;                         //Sets SMTP authentication. Utilizes the Username and Password variables
  41.         $mail->SMTPDebug = 0;  // debug: 1 = solo messaggi, 2 = errori e messaggi  
  42.         $mail->Username = 'EMAIL@gmail.com';                    //Sets SMTP username
  43.         $mail->Password = 'PASSWORD';                   //Sets SMTP password
  44.         $mail->SMTPSecure = 'ssl';                          //Sets connection prefix. Options are "", "ssl" or "tls"
  45.         $mail->From = 'mittente@gmail.com';         //Sets the From email address for the message
  46.         $mail->FromName = 'Nome';                   //Sets the From name of the message
  47.         $mail->AddAddress('destinatario@gmail.com','TIA');  //Adds a "To" address
  48.         $mail->WordWrap = 50;                           //Sets word wrapping on the body of the message to a given number of characters
  49.         $mail->IsHTML(true);                            //Sets message type to HTML
  50.         $mail->Subject = 'Alert Prodotti '.$data; //Sets the Subject of the message
  51.         //An HTML or plain text message body
  52.         $mail->Body = 'Totale Prodotti da ordinare: '.$count_prodotti.'<br>'.$output;
  53.  
  54.         $mail->AltBody = 'Body';
  55.         //$pdfString = $pdf->output();
  56.         //$mail->addStringAttachment($pdfString, $file_name);
  57.         $result = $mail->Send();                        //Send an Email. Return true on success or false on error  
  58.  
  59.  
  60.  
  61.        
  62.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement