Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.53 KB | None | 0 0
  1. <?php
  2. require_once('phpmailer/PHPMailerAutoload.php');
  3. include('config.php');
  4.  
  5. $mail = new PHPMailer;
  6.  
  7. $mail->CharSet = 'utf-8';
  8. $mail->isSMTP();                                      
  9. $mail->Host = 'smtp.mail.ru';  
  10. $mail->SMTPAuth = true;                          
  11. $mail->Username = 'test@mail.ru';
  12. $mail->Password = 'pass';
  13. $mail->SMTPSecure = 'ssl';                            
  14. $mail->Port = 465;
  15. $mail->setFrom('test@mail.ru');
  16. $mail->addAddress('test@test');     // Кому будет уходить письмо
  17. $mail->isHTML(true);    // Set email format to HTML
  18.  
  19. $mail->Subject = 'Заявка с тестового сайта';
  20.  
  21. //$result=mysqli_query($mysqli,"select * from users where id=$id");
  22.  
  23. $mail->Body = '<table>';
  24. $mail->Body .= '<tr>';
  25. $mail->Body .= '<th>Model</th>';
  26. $mail->Body .= '<th>Issue</th>';
  27. $mail->Body .= '<th>Email</th>';
  28. $mail->Body .= '<th>Comment</th>';
  29. $mail->Body .= '<tr>';
  30. if (isset($_POST['send'])){
  31.                 foreach ($_POST['id'] as $id):
  32. $result=mysqli_query($mysqli,"select * from users where id=$id");
  33.     while($res = mysqli_fetch_array($result)){
  34. $mail->Body .= '<tr>';
  35. $mail->Body .= '<td>' . $res["name"] . '</td>';
  36. $mail->Body .= '<td>' . $res["age"] . '</td>';
  37. $mail->Body .= '<td>' . $res["email"] . '</td>';
  38. $mail->Body .= "<td>" . $res["comment"] . '</td>';
  39. $mail->Body .= '</tr>';
  40.                                              }
  41. $mail->Body .= '</table>';
  42.  
  43. $mail->AltBody = '';
  44.  
  45. if(!$mail->send()) {
  46.     echo 'Error';
  47. } else {
  48.     header('location: index.php');
  49. }
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement