Guest User

Untitled

a guest
Aug 8th, 2018
905
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. <?php require 'class/class.phpmailer.php';
  2.  
  3. if (isset($_POST["submit"])) {
  4. $name = $_POST['name'];
  5.  
  6. $bodyContent = "hello ".$name;
  7.  
  8. $mail = new PHPMailer;
  9. $mail->CharSet = "UTF-8";
  10. $mail->IsSMTP(); //Sets Mailer to send message using SMTP
  11. $mail->Host = 'smtp.gmail.com'; //Sets the SMTP hosts of your Email hosting, this for Godaddy
  12. $mail->Port = '587'; //Sets the default SMTP server port
  13. $mail->SMTPAuth = true; //Sets SMTP authentication. Utilizes the Username and Password variables
  14. $mail->Username = 'username@gmail.com'; //Sets SMTP username
  15. $mail->Password = 'password'; //Sets SMTP password
  16. $mail->SMTPSecure = 'tls'; //Sets connection prefix. Options are "", "ssl" or "tls"
  17. $mail->From = "from@gmail.com"; //Sets the From email address for the message
  18. $mail->FromName = 'From Name'; //Sets the From name of the message
  19. $mail->AddAddress("address@gmail.com", "Name"); //Adds a "To" address
  20. $mail->AddCC("cc@gmail.com ", "CC Name"); //Adds a "Cc" address
  21. $mail->AddCC("cc1@gmail.com", "CC1 Name"); //Adds a "Cc" address
  22. $mail->WordWrap = 50; //Sets word wrapping on the body of the message to a given number of characters
  23. $mail->Hostname = 'localhost.localdomain'; //to send unlimited emails from localhost
  24. $mail->IsHTML(true); //Sets message type to HTML
  25. $mail->Subject = "Subject"; //Sets the Subject of the message
  26. $mail->Body = $bodyContent; //An HTML or plain text message body
  27. if ($mail->Send()) //Send an Email. Return true on success or false on error
  28. {
  29. echo "<SCRIPT type='text/javascript'>
  30. alert('Contact Form Successfully Submitted!');
  31. window.location.replace('thanks.php');</SCRIPT>";
  32. } else {
  33. echo "<SCRIPT type='text/javascript'>
  34. alert('Your form could not be sent. Please try again later.');
  35. window.location.replace('thanks.php');</SCRIPT>";
  36. // header("Refresh:0");
  37. }
  38. }
  39. ?>
Add Comment
Please, Sign In to add comment