Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2016
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. <div class="col-md-9 wow fadeInRight animated">
  2. <form class="contact-form" action="/email.php" method="post" >
  3. <div class="row">
  4. <div class="col-md-6">
  5. <input type="text" class="form-control" name="sender" id="sender" placeholder="Name">
  6. <input type="email" class="form-control" name="senderemail" id="email" placeholder="Email">
  7. <input type="text" class="form-control" name="sendsubject" id="subject" placeholder="Subject">
  8. </div>
  9. <div class="col-md-6">
  10. <textarea class="form-control" style="resize:none" name="sendermessage" id="message" rows="25" cols="20" placeholder="Type message here..."></textarea>
  11. <input type="submit" name="submit" class="btn btn-default submit-btn form_submit" value="SEND MESSAGE"></input>
  12. </div>
  13. </div>
  14. </form>
  15. </div>
  16.  
  17. <?php
  18.  
  19. if(isset($_POST['submit'])) {
  20. $recipient='naman.mandhan@gmail.com';
  21. $subject=$_POST['sendersubject'];
  22. $sender=$_POST['sender'];
  23. $senderEmail=$_POST['senderemail'];
  24. $message=$_POST['sendermessage'];
  25.  
  26. //$mailBody="Name: $sendernEmail: $senderEmailnn$message";
  27.  
  28. mail($recipient, $subject, $mailBody, "From: $sender <$senderEmail>");
  29.  
  30. }
  31. ?>
  32.  
  33. <?php
  34. require 'PHPMailer/PHPMailerAutoload.php';
  35.  
  36. //Create a new PHPMailer instance
  37. $mail = new PHPMailer;
  38.  
  39. //Tell PHPMailer to use SMTP
  40. $mail->isSMTP();
  41.  
  42. //Enable SMTP debugging
  43. // 0 = off (for production use)
  44. // 1 = client messages
  45. // 2 = client and server messages
  46. $mail->SMTPDebug = 2;
  47.  
  48. //Ask for HTML-friendly debug output
  49. $mail->Debugoutput = 'html';
  50.  
  51. //Set the hostname of the mail server
  52. $mail->Host = 'smtp.gmail.com';
  53. // use
  54. // $mail->Host = gethostbyname('smtp.gmail.com');
  55. // if your network does not support SMTP over IPv6
  56.  
  57. //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
  58. $mail->Port = 587;
  59.  
  60. //Set the encryption system to use - ssl (deprecated) or tls
  61. $mail->SMTPSecure = 'tls';
  62.  
  63. //Whether to use SMTP authentication
  64. $mail->SMTPAuth = true;
  65.  
  66. //Username to use for SMTP authentication - use full email address for gmail
  67. $mail->Username = "naman.mandhan@gmail.com";
  68.  
  69. //Password to use for SMTP authentication
  70. $mail->Password = "nahdnam";
  71.  
  72. //Set who the message is to be sent from
  73. $mail->setFrom($senderEmail, $sender);
  74.  
  75. //Set an alternative reply-to address
  76. //$mail->addReplyTo('replyto@example.com', 'First Last');
  77.  
  78. //Set who the message is to be sent to
  79. $mail->addAddress($recipient, 'Naman Mandhan');
  80.  
  81. //Set the subject line
  82. $mail->Subject = $subject;
  83.  
  84. //Read an HTML message body from an external file, convert referenced images to embedded,
  85. //convert HTML into a basic plain-text alternative body
  86. //$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
  87.  
  88. //Include the sender message in the body
  89. $mail->Body = $message;
  90. $mail->AltBody = $message;
  91.  
  92. //Attach an image file
  93. //$mail->addAttachment('images/phpmailer_mini.png');
  94.  
  95. //send the message, check for errors
  96. if (!$mail->send()) {
  97. echo "Mailer Error: " . $mail->ErrorInfo;
  98. } else {
  99. echo "Message sent!";
  100. }
  101.  
  102. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement