Advertisement
Guest User

Untitled

a guest
Sep 14th, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.78 KB | None | 0 0
  1. <?php
  2.  
  3. require 'phpmailer/PHPMailerAutoload.php';
  4.  
  5.  
  6. /*проверяем, если файл загружен и ошибок нет*/
  7. if($_FILES['upload']['error'] == 0){
  8. /*выбираем путь временного хранилища файла*/
  9. $temp = $_FILES['upload']['tmp'];
  10. /*выбираем путь, куда будем сохранять файл*/
  11. $name_file = $_FILES['upload']['name'];
  12. /*перемещаем файл из временной папки к нам на сервер*/
  13. move_uploaded_file($temp, "uploads/".$name_file);
  14.  
  15.  
  16.  
  17. $mail = new PHPMailer;
  18.  
  19. //$mail->SMTPDebug = 3;                               // Enable verbose debug output
  20.  
  21. $mail->isSMTP();                                      // Set mailer to use SMTP
  22. $mail->Host = ;
  23. $mail->SMTPAuth = true;                               // Enable SMTP authentication
  24. $mail->Username = ;
  25. $mail->Password = ;
  26. $mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
  27. $mail->Port = 465;                                    // TCP port to connect to
  28. $mail->From = ;
  29. $mail->FromName = 'Mailer';
  30. $mail->addAddress('', 'Joe User');     // Add a recipient
  31.  
  32.  
  33.  
  34.    
  35. $mail->addAttachment("uploads/".$name_file);         // Add attachments
  36.  
  37.                                   // Set email format to HTML
  38.  
  39. $mail->Subject = 'Here is the subject';
  40. $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
  41. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  42. $mail->IsHTML(true);
  43. if(!$mail->send()) {
  44.   unlink('uploads/'.$name_file);
  45.     echo 'Message could not be sent.';
  46.     echo 'Mailer Error: ' . $mail->ErrorInfo;
  47.  
  48. } else {
  49.    unlink("uploads/".$name_file);
  50.     echo 'Message has been sent';
  51.  
  52. }
  53. }
  54. else {
  55.  echo 'error';
  56. }
  57.  
  58. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement