Guest User

Untitled

a guest
Feb 9th, 2018
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. <form enctype="multipart/form-data" id="contact-form-cv" name="contact-form-cv" method="POST" data-name="Contact Form CV">
  2.  
  3. <div class="form-group">
  4.  
  5. <div class="controls">
  6.  
  7. <!-- FILE -->
  8. <input type="hidden" name="MAX_FILE_SIZE" value="300000">
  9. <input type="file" name="cv-file" id="file" class="input-file form-control special-form my-file">
  10. <label for="file" class="btn btn-tertiary js-labelFile">
  11.  
  12. <span class="js-fileName"><i class="fa fa-upload"></i>&nbsp; Attach CV*</span>
  13. </label>
  14.  
  15. <!-- Button -->
  16. <button id="cv-valid-form" type="submit" class="btn btn-lg submit">Submit</button>
  17.  
  18. </div>
  19.  
  20. </div>
  21.  
  22. <?php
  23. if($_POST) {
  24.  
  25. date_default_timezone_set('Etc/UTC');
  26.  
  27. // require_once('phpmailer/PHPMailerAutoload.php');
  28. require_once ('phpmailer/PHPMailerAutoload.php');
  29.  
  30. $uploadfile = tempnam(sys_get_temp_dir(), sha1($_FILES['cv-file']['name']));
  31.  
  32. $mail = new PHPMailer();
  33.  
  34. //Set PHPMailer to use SMTP.
  35. $mail->isSMTP();
  36. //Enable SMTP debugging.
  37. $mail->SMTPDebug = 0;
  38. //Ask for HTML-friendly debug output
  39. $mail->Debugoutput = 'html';
  40. //Set SMTP host name
  41. $mail->Host = 'smtp.gmail.com';
  42. //Set TCP port to connect to
  43. $mail->Port = 587;
  44. //Set the encryption system to use - ssl (deprecated) or tls
  45. $mail->SMTPSecure = 'tls';
  46. //Set this to true if SMTP host requires authentication to send email
  47. $mail->SMTPAuth = true;
  48.  
  49. $mail->isHTML(true);
  50.  
  51. //Provide username and password yo your google account
  52. $mail->Username = "*******@gmail.com";
  53. $mail->Password = "*******";
  54.  
  55. //Set who the message is to be sent from
  56. $mail->setFrom('******@gmail.com', 'Jony');
  57. //Set an alternative reply-to address
  58. // $mail->addReplyTo('replyto@example.com', 'First Last');
  59. //Set who the message is to be sent to
  60. $mail->addAddress('*****@gmail.com', 'John Doe');
  61. //Set the subject line
  62. $mail->Subject = 'New message from my website!';
  63.  
  64. //Replace the plain text body with one created manually
  65. $mail->Body = 'hello' . "rn" ;
  66.  
  67.  
  68. $mail->addAttachment($uploadfile, 'UPLOAD file');
  69.  
  70.  
  71.  
  72. if(!$mail->send())
  73. {
  74. $output = json_encode(array('type'=>'error', 'text' => '<i class="icon ion-close-round"></i> Oops! Looks like something went wrong, please check your PHP mail configuration.'));
  75. die($output);
  76. }
  77. else
  78. {
  79. $output = json_encode(array('type'=>'message', 'text' => '<i class="icon ion-checkmark-round"></i> Hello '.$_POST["userName"] .', Your message has been sent, we will get back to you asap !'));
  80. die($output);
  81. }
  82. }
  83. ?>
Add Comment
Please, Sign In to add comment