Advertisement
Guest User

Finally

a guest
Dec 13th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. <?php
  2. $msg = "";
  3. use PHPMailer\PHPMailer\PHPMailer;
  4. include_once "PHPMailer/PHPMailer.php";
  5. include_once "PHPMailer/Exception.php";
  6. include_once "PHPMailer/SMTP.php";
  7.  
  8. if (isset($_POST['submit'])) {
  9. $subject = $_POST['subject'];
  10. $email = $_POST['email'];
  11. $message = $_POST['message'];
  12.  
  13. $mail = new PHPMailer();
  14.  
  15. //if we want to send via SMTP
  16. $mail->Host = "smtp.mail.com";
  17. $mail->isSMTP();
  18. $mail->SMTPAuth = true;
  19. $mail->Username = "mail@mail.com";
  20. $mail->Password = "12345";
  21. $mail->SMTPSecure = "tls"; //TLS
  22. $mail->Port = 587; //587
  23.  
  24. $mail->addAddress('mail@mail.com');
  25. $mail->setFrom('mail@mail.com', 'Guest');
  26. $mail->Subject = $subject;
  27. $mail->isHTML(true);
  28. $mail->Body = $message;
  29.  
  30. if ($mail->send())
  31. $msg = "Your email has been sent, thank you!";
  32. else
  33. //$msg = "Please try again!";
  34. echo $mail->ErrorInfo;
  35. }
  36. ?>
  37.  
  38. <!doctype html>
  39. <html lang="en">
  40. <head>
  41. <meta charset="UTF-8">
  42. <meta name="viewport"
  43. content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  44. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  45. <title>Contact Form</title>
  46. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
  47. </head>
  48. <body>
  49. <div class="container" style="margin-top: 100px">
  50. <div class="row justify-content-center">
  51. <div class="col-md-6 col-md-offset-3" align="center">
  52. <br><br>
  53.  
  54. <?php if ($msg != "") echo "$msg<br><br>"; ?>
  55.  
  56. <form method="post" action="sendemail.php">
  57. <input class="form-control" name="subject" placeholder="Subject..."><br>
  58. <input class="form-control" name="email" type="email" placeholder="Email..."><br>
  59. <textarea placeholder="Message..." class="form-control" name="message"></textarea><br>
  60. <input class="btn btn-primary" name="submit" type="submit" value="Send Email">
  61. </form>
  62. </div>
  63. </div>
  64. </div>
  65. </body>
  66. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement