Guest User

Untitled

a guest
Sep 1st, 2018
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. <?php
  2. $msg = "";
  3. use PHPMailerPHPMailerPHPMailer;
  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.gmail.com";
  17. //$mail->isSMTP();
  18. $mail->SMTPAuth = true;
  19. $mail->Username = "abc@gmail.com";
  20. $mail->Password = "mypassword";
  21. $mail->SMTPSecure = "ssl"; //TLS
  22. $mail->Port = 465; //587
  23.  
  24. $mail->addAddress('ammarkashmiri@gmail.com');
  25. $mail->setFrom($email);
  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. }
  35. ?>
  36. <!doctype html>
  37. <html lang="en">
  38. <head>
  39. <meta charset="UTF-8">
  40. <meta name="viewport"
  41. content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  42. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  43. <title>Contact Form</title>
  44. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
  45. </head>
  46. <body>
  47. <div class="container" style="margin-top: 100px">
  48. <div class="row justify-content-center">
  49. <div class="col-md-6 col-md-offset-3" align="center">
  50. <img src="images/logo.png"><br><br>
  51.  
  52. <?php if ($msg != "") echo "$msg<br><br>"; ?>
  53.  
  54. <form method="post" action="sendemail.php">
  55. <input class="form-control" name="subject" placeholder="Subject..."><br>
  56. <input class="form-control" name="email" type="email" placeholder="Email..."><br>
  57. <textarea placeholder="Message..." class="form-control" name="message"></textarea><br>
  58. <input class="btn btn-primary" name="submit" type="submit" value="Send Email">
  59. </form>
  60. </div>
  61. </div>
  62. </div>
  63. </body>
  64. </html>
Add Comment
Please, Sign In to add comment