Advertisement
Guest User

Untitled

a guest
Nov 30th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. <?php
  2. require 'PHPMailerAutoload.php';
  3. if(isset($_POST['send']))
  4. {
  5. // Fetching data that is entered by the user
  6. $email = $_POST['email'];
  7. $password = $_POST['password'];
  8. $to_id = $_POST['toid'];
  9. $message = $_POST['message'];
  10. $subject = $_POST['subject'];
  11.  
  12. // Configuring SMTP server settings
  13. $mail = new PHPMailer;
  14. $mail->isSMTP();
  15. $mail->Host = 'smtp.gmail.com';
  16. $mail->Port = 587;
  17. $mail->SMTPSecure = 'tls';
  18. $mail->SMTPAuth = true;
  19. $mail->Username = $email;
  20. $mail->Password = $password;
  21.  
  22. // Email Sending Details
  23. $mail->addAddress($to_id);
  24. $mail->Subject = $subject;
  25. $mail->msgHTML($message);
  26.  
  27. // Success or Failure
  28. if (!$mail->send()) {
  29. $error = "Mailer Error: " . $mail->ErrorInfo;
  30. echo '<p id="para">'.$error.'</p>';
  31. }
  32. else {
  33. echo '<p id="para">Message sent!</p>';
  34. }
  35. }
  36. else{
  37. echo '<p id="para">Please enter valid data</p>';
  38. }
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement