Advertisement
Guest User

Untitled

a guest
Mar 16th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.16 KB | None | 0 0
  1. #user nobody;
  2.  
  3. worker_processes 2;
  4.  
  5. events {
  6. worker_connections 1024;
  7. }
  8.  
  9. http {
  10. include mime.types;
  11. default_type application/octet-stream;
  12.  
  13. sendfile on;
  14. keepalive_timeout 65;
  15.  
  16. server {
  17. listen 80;
  18. server_name localhost;
  19.  
  20. location / {
  21. try_files $uri $uri/ /index.php;
  22. root html;
  23. index index.php index.html index.htm;
  24. }
  25.  
  26. #error_page 404 /404.html;
  27.  
  28. # redirect server error pages to the static page /50x.html
  29. error_page 500 502 503 504 /50x.html;
  30. location = /50x.html {
  31. root html;
  32. }
  33.  
  34. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  35. location ~ .php$ {
  36. root html;
  37. fastcgi_pass 127.0.0.1:9000;
  38. fastcgi_index index.php;
  39. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  40. include fastcgi_params;
  41. }
  42. }
  43. }
  44.  
  45. mail {
  46. server_name 192.168.1.104;
  47. auth_http 192.168.1.104/auth.php;
  48. auth_http_header X-Auth-Key "secret_string";
  49. auth_http_timeout 60s;
  50.  
  51. proxy on;
  52. xclient off;
  53.  
  54. smtp_auth login plain cram-md5;
  55. pop3_auth plain apop cram-md5;
  56.  
  57. imap_capabilities IMAP4rev1 UIDPLUS IDLE LITERAL+ QUOTA;
  58. pop3_capabilities LAST TOP USER PIPELINING UIDL;
  59. smtp_capabilities "SIZE 20480000" ENHANCEDSTATUSCODES 8BITMIME DSN;
  60.  
  61. server {
  62. listen 26 so_keepalive=on;
  63. protocol smtp;
  64. }
  65. server {
  66. listen 111 so_keepalive=on;
  67. protocol pop3;
  68. proxy_pass_error_message on;
  69.  
  70. }
  71. server {
  72. listen 144 so_keepalive=on;
  73. protocol imap;
  74. }
  75. }
  76.  
  77. <?php
  78. date_default_timezone_set('Asia/Taipei');
  79. include("PHPMailerAutoload.php");
  80. $mail= new PHPMailer();
  81. $mail->IsSMTP();
  82. $mail->SMTPAuth = true;
  83. $mail->SMTPSecure = false;
  84. $mail->Host = "192.168.1.104";
  85. // If I use port 25, it will work well. But if so, that doesn't through a proxy.
  86. $mail->Port = 26;
  87. $mail->CharSet = "UTF-8";
  88.  
  89. $mail->Username = "mail01@192.168.1.104";
  90. $mail->Password = "123456";
  91.  
  92. $mail->From = "mail01@192.168.1.104";
  93. $mail->FromName = "Test Name";
  94.  
  95. $mail->Subject = "Test Subject";
  96. $mail->Body = "Hello! Here is body ";
  97. $mail->IsHTML(true);
  98. $mail->AddAddress("mail01@192.168.1.104", "Mark");
  99. if(!$mail->Send()) {
  100. echo "Mailer Error: " . $mail->ErrorInfo;
  101. } else {
  102. echo "Message sent!";
  103. }
  104. ?>
  105.  
  106. <?php
  107. // If I use port 143, it will work well. But if so, that doesn't through a proxy.
  108. $hostname = '{192.168.1.104:144}INBOX';
  109. $username = 'mail01@192.168.1.104';
  110. $password = '123456';
  111.  
  112. $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to hmail server: ' . imap_last_error());
  113.  
  114. $emails = imap_search($inbox,'ALL');
  115.  
  116. if($emails) {
  117. $output = '';
  118. rsort($emails);
  119.  
  120. foreach($emails as $email_number) {
  121. $overview = imap_fetch_overview($inbox,$email_number,0);
  122. $message = imap_fetchbody($inbox,$email_number,1);
  123.  
  124. $output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';
  125. $output.= '<span class="subject">'.$overview[0]->subject.'</span> ';
  126. $output.= '<span class="from">'.$overview[0]->from.'</span>';
  127. $output.= '<span class="date">on '.$overview[0]->date.'</span>';
  128. $output.= '</div>';
  129.  
  130. $output.= '<div class="body">'.$message.'</div>';
  131. $output.= '<br>';
  132. }
  133. echo $output;
  134. }
  135. imap_close($inbox);
  136. ?>
  137.  
  138. <?php
  139. if (!isset($_SERVER["HTTP_AUTH_USER"] ) || !isset($_SERVER["HTTP_AUTH_PASS"] )){
  140. fail();
  141. }
  142.  
  143. $username=$_SERVER["HTTP_AUTH_USER"] ;
  144. $userpass=$_SERVER["HTTP_AUTH_PASS"] ;
  145. $protocol=$_SERVER["HTTP_AUTH_PROTOCOL"] ;
  146.  
  147. // default backend port
  148. $backend_port=110;
  149.  
  150. if ($protocol=="imap") {
  151. $backend_port=143;
  152. }
  153.  
  154. if ($protocol=="smtp") {
  155. $backend_port=25;
  156. }
  157.  
  158. if($username == "mail01@192.168.1.104"){
  159. $server_ip = "192.168.1.104";
  160. }
  161.  
  162. pass($server_ip, $backend_port);
  163.  
  164. function fail(){
  165. header("Auth-Status: Invalid login or password");
  166. exit;
  167. }
  168.  
  169. function pass($server,$port){
  170. header("Auth-Status: OK");
  171. header("Auth-Server: $server");
  172. header("Auth-Port: $port");
  173. exit;
  174. }
  175. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement