Advertisement
Guest User

Untitled

a guest
Aug 31st, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. <?php
  2. $mailto = $_POST['mail_to'];
  3.  
  4. $mailSub = $_POST['mail_sub'];
  5.  
  6. $mailMsg = $_POST['mail_msg'];
  7.  
  8. $attachment = $_FILES['attachment'];
  9.  
  10. require 'PHPMailer-master/PHPMailerAutoload.php';
  11.  
  12. $mail = new PHPMailer();
  13.  
  14. $mail ->IsSmtp();
  15.  
  16. $mail ->SMTPDebug = 1;
  17.  
  18. $mail ->SMTPAuth = true;
  19.  
  20. $mail ->SMTPSecure = 'ssl';
  21.  
  22. $mail ->Host = "smtp.gmail.com";
  23.  
  24. $mail ->Port = 465; // or 587
  25.  
  26. $mail ->IsHTML(true);
  27.  
  28. $mail ->Username = "#######@gmail.com";
  29.  
  30. $mail ->Password = "########";
  31.  
  32. $mail ->SetFrom("#######@gmail.com");
  33.  
  34. $mail ->Subject = $mailSub;
  35.  
  36. $mail ->Body = $mailMsg;
  37.  
  38. $mail ->AddAddress($mailto);
  39.  
  40. $mail ->AddAttachment($attachment);
  41.  
  42. $file = "attachment/" . basename($_FILES['attachment']['name']);
  43.  
  44.  
  45. if(!$mail->Send())
  46. {
  47.  
  48.  
  49.  
  50. echo "Mail Not Sent";
  51.  
  52.  
  53.  
  54. }
  55.  
  56.  
  57.  
  58.  
  59.  
  60. else
  61.  
  62.  
  63.  
  64. {
  65.  
  66.  
  67.  
  68. echo "Mail Sent";
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement