Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. <?php
  2. include_once 'db_connect.php';
  3.  
  4. require 'phpmailer/PHPMailerAutoload.php';
  5. $mail = new PHPMailer;
  6.  
  7.  
  8. function sendFormEmail($mail, $to, $subject, $senderName, $senderEmail, $message, $sendCopy) {
  9. $_SESSION['token'] = random_string(50);
  10. $subject = filter_var($subject, FILTER_SANITIZE_STRING);
  11. $senderName = filter_var($senderName, FILTER_SANITIZE_STRING);
  12. $senderEmail = filter_var($senderEmail, FILTER_SANITIZE_EMAIL);
  13. $message = filter_var($_POST['body'], FILTER_SANITIZE_STRING);
  14.  
  15. $mail->isSMTP(); // Set mailer to use SMTP
  16. $mail->Host = 'mail.privateemail.com'; // Specify main and backup SMTP servers
  17. $mail->SMTPDebug = 2;
  18. $mail->SMTPAuth = true; // Enable SMTP authentication
  19. $mail->Username = 'my-email'; // SMTP username
  20. $mail->Password = 'my-pass'; // SMTP password
  21. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  22. $mail->Port = 25; // TCP port to connect to
  23.  
  24. $mail->setFrom('webmaster@mysite.com', 'mysite.com');
  25. $mail->addAddress('my-email', 'me');
  26. $mail->addReplyTo($senderEmail, $senderName);
  27.  
  28. $mail->Subject = "mysite.com: " . $subject;
  29. $mail->Body = "<h1>You've received a message through the contact form at mysite.com: </h1><br><p style='white-space: pre-wrap;'>" . $message . "</p>";
  30. $mail->AltBody = "You've received a message through the contact form at mysite.com: " . $message;
  31.  
  32. if($mail->send()) {
  33. return "wooho!";
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement