Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.63 KB | None | 0 0
  1. <?php
  2. @require_once('Mail.php');
  3. // Check for empty fields
  4. if (empty($_POST['name']) || empty($_POST['email']) || empty($_POST['phone']) ||
  5.    empty($_POST['message']) || !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)) {
  6.   echo "No arguments Provided!";
  7.   return false;
  8. }
  9.  
  10. // This configures the host information
  11. $from = "NoReply <noreply@rooshivkumar.com>";
  12. $to = "roo@rooshivkumar.com";
  13. $host = "ssl://send.one.com";
  14. $port = "465";
  15. $username = "noreply@rooshivkumar.com";
  16. $password = "";
  17.  
  18. // Get file information
  19. $handler = fopen("config/10bdac23491231001239439234adbecadbc.cfg", "r");
  20. if ($handler) {
  21.   $password = base64_decode(base64_decode(fgets($handler)));
  22.   fclose($handler);
  23. }
  24. else {
  25.   echo "Failed to log into SMTP server to send information";
  26.   return false;
  27. }
  28.  
  29. $name = $_POST['name'];
  30. $email_address = $_POST['email'];
  31. $phone = $_POST['phone'];
  32. $message = $_POST['message'];
  33.    
  34. // Create the email and send the message
  35. $email_subject = "Website Contact Form:  $name";
  36. $email_body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\nMessage:\n$message";
  37. $headers = array ('From' => $from,
  38.    'To' => $to,
  39.    'Subject' => $email_subject);
  40. $smtp = @Mail::factory('smtp',
  41.    array('host' => $host,
  42.       'port' => $port,
  43.       'auth' => true,
  44.       'username' => $username,
  45.       'password' => $password
  46.    )
  47. );
  48. $mail = @$smtp->send($to, $headers, $email_body);
  49. if ($mail != 1) {
  50.    echo "Unable to send contact information.";
  51.    return false;
  52. }
  53. echo "Your request was successful";
  54. return true;
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement