Advertisement
Guest User

Untitled

a guest
Feb 18th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. <?php
  2.  
  3. if(empty($_POST['email']) ||
  4. empty($_POST['phone']) ||
  5. empty($_POST['message']) ||
  6. !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
  7. {
  8. echo "No arguments Provided!";
  9. return false;
  10. }
  11.  
  12. $email_address = $_POST['email'];
  13. $phone = $_POST['phone'];
  14. $message = $_POST['message'];
  15.  
  16.  
  17. ini_set('default_socket_timeout', 3);
  18.  
  19. function smtp_mail($to, $from, $message, $user, $pass, $host, $port)
  20. {
  21. if ($h = fsockopen($host, $port))
  22. {
  23. $data = array(
  24. 0,
  25. "EHLO $host",
  26. 'AUTH LOGIN',
  27. base64_encode($user),
  28. base64_encode($pass),
  29. "MAIL FROM: <$from>",
  30. "RCPT TO: <$to>",
  31. 'DATA',
  32. $message
  33. );
  34.  
  35. foreach($data as $c)
  36. {
  37. $c && fwrite($h, "$c\r\n");
  38. while(substr(fgets($h, 256), 3, 1) != ' '){}
  39. }
  40.  
  41. fwrite($h, "QUIT\r\n");
  42. return fclose($h);
  43. }
  44. }
  45.  
  46. $user = 'no.reply.tweetangels@gmail.com';
  47. $pass = 'pass';
  48. $host = 'ssl://smtp.gmail.com';
  49. //$host = 'ssl://email-smtp.us-east-1.amazonaws.com'; //Amazon SES
  50. $port = 465;
  51.  
  52. $to = 'sales@tweetangels.com';
  53. $from = 'no.reply.tweetangels@gmail.com';
  54. $template = "Subject: Application from the site\r\n"
  55. ."To: <sales@tweetangels.com>\r\n"
  56. ."From: no.reply.tweetangels@gmail.com\r\n"
  57. ."MIME-Version: 1.0\r\n"
  58. ."Content-Type: text/html; charset=utf-8\r\n"
  59. ."Content-Transfer-Encoding: QUOTED-PRINTABLE\r\n\r\n"
  60. ."Email: $email_address <br>\r\n"
  61. ."Phone: $phone <br>\r\n"
  62. ."Message: $message\r\n"
  63. ."<br><br><br><hr>Coded By: <a href='http://www.facebook.com/slaki011/'>Slavisa</a>\r\n.";
  64.  
  65.  
  66. if(smtp_mail($to, $from, $template, $user, $pass, $host, $port))
  67. {
  68. echo "Mail sent\n\n";
  69. }
  70. else
  71. {
  72. echo "Some error occured\n\n";
  73. }
  74. return true;
  75. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement