Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #user nobody;
- worker_processes 2;
- events {
- worker_connections 1024;
- }
- http {
- include mime.types;
- default_type application/octet-stream;
- sendfile on;
- keepalive_timeout 65;
- server {
- listen 80;
- server_name localhost;
- location / {
- try_files $uri $uri/ /index.php;
- root html;
- index index.php index.html index.htm;
- }
- #error_page 404 /404.html;
- # redirect server error pages to the static page /50x.html
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
- # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
- location ~ .php$ {
- root html;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- include fastcgi_params;
- }
- }
- }
- mail {
- server_name 192.168.1.104;
- auth_http 192.168.1.104/auth.php;
- auth_http_header X-Auth-Key "secret_string";
- auth_http_timeout 60s;
- proxy on;
- xclient off;
- smtp_auth login plain cram-md5;
- pop3_auth plain apop cram-md5;
- imap_capabilities IMAP4rev1 UIDPLUS IDLE LITERAL+ QUOTA;
- pop3_capabilities LAST TOP USER PIPELINING UIDL;
- smtp_capabilities "SIZE 20480000" ENHANCEDSTATUSCODES 8BITMIME DSN;
- server {
- listen 26 so_keepalive=on;
- protocol smtp;
- }
- server {
- listen 111 so_keepalive=on;
- protocol pop3;
- proxy_pass_error_message on;
- }
- server {
- listen 144 so_keepalive=on;
- protocol imap;
- }
- }
- <?php
- date_default_timezone_set('Asia/Taipei');
- include("PHPMailerAutoload.php");
- $mail= new PHPMailer();
- $mail->IsSMTP();
- $mail->SMTPAuth = true;
- $mail->SMTPSecure = false;
- $mail->Host = "192.168.1.104";
- // If I use port 25, it will work well. But if so, that doesn't through a proxy.
- $mail->Port = 26;
- $mail->CharSet = "UTF-8";
- $mail->Username = "mail01@192.168.1.104";
- $mail->Password = "123456";
- $mail->From = "mail01@192.168.1.104";
- $mail->FromName = "Test Name";
- $mail->Subject = "Test Subject";
- $mail->Body = "Hello! Here is body ";
- $mail->IsHTML(true);
- $mail->AddAddress("mail01@192.168.1.104", "Mark");
- if(!$mail->Send()) {
- echo "Mailer Error: " . $mail->ErrorInfo;
- } else {
- echo "Message sent!";
- }
- ?>
- <?php
- // If I use port 143, it will work well. But if so, that doesn't through a proxy.
- $hostname = '{192.168.1.104:144}INBOX';
- $username = 'mail01@192.168.1.104';
- $password = '123456';
- $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to hmail server: ' . imap_last_error());
- $emails = imap_search($inbox,'ALL');
- if($emails) {
- $output = '';
- rsort($emails);
- foreach($emails as $email_number) {
- $overview = imap_fetch_overview($inbox,$email_number,0);
- $message = imap_fetchbody($inbox,$email_number,1);
- $output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';
- $output.= '<span class="subject">'.$overview[0]->subject.'</span> ';
- $output.= '<span class="from">'.$overview[0]->from.'</span>';
- $output.= '<span class="date">on '.$overview[0]->date.'</span>';
- $output.= '</div>';
- $output.= '<div class="body">'.$message.'</div>';
- $output.= '<br>';
- }
- echo $output;
- }
- imap_close($inbox);
- ?>
- <?php
- if (!isset($_SERVER["HTTP_AUTH_USER"] ) || !isset($_SERVER["HTTP_AUTH_PASS"] )){
- fail();
- }
- $username=$_SERVER["HTTP_AUTH_USER"] ;
- $userpass=$_SERVER["HTTP_AUTH_PASS"] ;
- $protocol=$_SERVER["HTTP_AUTH_PROTOCOL"] ;
- // default backend port
- $backend_port=110;
- if ($protocol=="imap") {
- $backend_port=143;
- }
- if ($protocol=="smtp") {
- $backend_port=25;
- }
- if($username == "mail01@192.168.1.104"){
- $server_ip = "192.168.1.104";
- }
- pass($server_ip, $backend_port);
- function fail(){
- header("Auth-Status: Invalid login or password");
- exit;
- }
- function pass($server,$port){
- header("Auth-Status: OK");
- header("Auth-Server: $server");
- header("Auth-Port: $port");
- exit;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement