Advertisement
Guest User

Untitled

a guest
Mar 11th, 2019
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. <form type="submit" enctype="multipart/form-data">
  2. <input type="file" name="attachment">
  3. <button name="submit" type="submit">SEND</button>
  4. </form>
  5.  
  6. if(isset($_POST['submit'])){
  7. extract($_POST);
  8.  
  9. $to="example@email.com";
  10. $msg="email body";
  11.  
  12. require 'include/PHPMailer_master/src/PHPMailer.php';
  13. require 'include/PHPMailer_master/src/SMTP.php';
  14. require 'include/PHPMailer_master/src/Exception.php';
  15. $mail = new PHPMailerPHPMailerPHPMailer(true);
  16.  
  17. enables exceptions
  18. try {
  19. //Server settings
  20. $mail->SMTPDebug = 2;
  21. $mail->isSMTP();
  22. $mail->Host = 'smtp.siteprotect.com';
  23. $mail->SMTPAuth = true;
  24. $mail->Username = 'example@email.com';
  25. $mail->Password = 'password';
  26. $mail->SMTPSecure = 'tls';
  27. $mail->Port = 587;
  28.  
  29. $mail->setFrom('example@email.com');
  30. $mail->addAddress($to);
  31.  
  32. $mail->addAttachment($_FILES['attachment']['tmp_name'],
  33. $_FILES['attachment']['name'] );
  34.  
  35. $mail->isHTML(true);
  36. $mail->Subject = 'RESUME - Sales Engineer (from website careers page)';
  37. $mail->Body = $msg;
  38. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  39. $mail->send();
  40. echo '<script>alert("Message has been sent");</script>';
  41. } catch (Exception $e) {
  42. echo '<script>alert("Message not sent");</script>';
  43. echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement