Guest User

Untitled

a guest
Mar 12th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. <?php
  2. // The FILTER_SANITIZE_STRING filter removes tags and remove or encode special characters from a string.
  3. $n = filter_var($_POST['CN'], FILTER_SANITIZE_STRING);
  4. $e = filter_var($_POST['CE'], FILTER_SANITIZE_STRING);
  5.  
  6.  
  7. require 'libs/PHPMailer/PHPMailerAutoload.php';
  8. $mail = new PHPMailer;
  9. $mail->SMTPDebug = 0;
  10. $mail->setFrom('***', 'Test1');
  11. $mail->addAddress('***', 'Test2');
  12. $mail->Subject = 'Request';
  13.  
  14. if (isset($_FILES['fileIMG']['name'])) {
  15. $mail->AddAttachment($_FILES['fileIMG']['tmp_name'],
  16. $_FILES['fileIMG']['name']);
  17. }
  18.  
  19. if (isset($_FILES['fileEAN']['name'])) {
  20. $mail->AddAttachment($_FILES['fileEAN']['tmp_name'],
  21. $_FILES['fileEAN']['name']);
  22. }
  23.  
  24. $body = file_get_contents('mail_template.html');
  25. $body = str_replace('%CN%', $n, $body);
  26. $body = str_replace('%CE%', $e, $body);
  27.  
  28. $mail->MsgHTML($body);
  29. $mail->IsHTML(true);
  30. $mail->CharSet="utf-8";
  31.  
  32. $mail->isSMTP();
  33. $mail->Host = '***';
  34. // optional
  35. // used only when SMTP requires authentication
  36. $mail->Port = 25;
  37. $mail->SMTPAuth = true;
  38. $mail->Username = '***';
  39. $mail->Password = '***';
  40.  
  41. if(!$mail->send()) {
  42. echo 'Error';
  43. } else {
  44. echo 'Success';
  45. }
  46. ?>
Add Comment
Please, Sign In to add comment