Welcome! Log In Create A New Profile

Advanced

Настройка mail-proxy

MKG
October 18, 2012 04:23AM
Хочу настроить mail-proxy для почты яндекса.
Сделал так (делаю пока под win2k3):



Файл nginx.conf
-----------------------------------------------------


worker_processes 1;

error_log logs/error.log;


events {
worker_connections 1024;
}






http {

include mime.types;
default_type application/octet-stream;


upstream auth_backend {
server 127.0.0.1:55680;
server 127.0.0.1:55681;
}



server {

listen 80 default;
server_name localhost;

server_tokens off;

access_log logs/access.log;

location / {
root public_html;
index index.html index.htm index.php;
}

location ~ \.php$ {

root public_html;

fastcgi_connect_timeout 1;
fastcgi_next_upstream timeout;
fastcgi_pass auth_backend;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


include fastcgi_params;
}

location ~ /\.ht {
deny all;
}


error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

}
}










mail {

server_name mail.example.com;
auth_http 127.0.0.1:16843/mail_auth.php;

proxy on;


pop3_auth plain apop cram-md5;
pop3_capabilities "LAST" "TOP" "USER" "PIPELINING" "UIDL";


server {
listen 110;
protocol pop3;
proxy_pass_error_message on;
}


xclient on;

server {
listen 25;
protocol smtp;
}

}

-----------------------------------------------------




Файл mail_auth.php
-----------------------------------------------------
<?php


ob_start();

$Was_Error = true;
$Error_Str = '';



if (isset($_SERVER['HTTP_AUTH_USER'])) { $User_Name = strtolower($_SERVER['HTTP_AUTH_USER']); } else { $User_Name = NULL; }
if (isset($_SERVER['HTTP_AUTH_PASS'])) { $User_Pass = $_SERVER['HTTP_AUTH_PASS']; } else { $User_Pass = NULL; }
if (isset($_SERVER['HTTP_AUTH_PROTOCOL'])) { $Protocol = strtolower($_SERVER['HTTP_AUTH_PROTOCOL']); } else { $Protocol = NULL; }
if (isset($_SERVER['HTTP_CLIENT_IP'])) { $Client_IP = $_SERVER['HTTP_CLIENT_IP']; } else { $Client_IP = NULL; }



$Mail_Server_Port = NULL;
if ($Protocol == 'smtp') { $Mail_Server_Port = 25; }
elseif ($Protocol == 'pop3') { $Mail_Server_Port = 110; }
else { /* ошибка - протокол не поддерживается*/ }






$Mail_Add_Arr = explode('@', $User_Name, 2);

if (isset($Mail_Add_Arr[0])) { $User_Mailbox_Part = strtolower($Mail_Add_Arr[0]); } else { $User_Mailbox_Part = NULL; }
if (isset($Mail_Add_Arr[1])) { $Mail_Server_Part = strtolower($Mail_Add_Arr[1]); } else { $Mail_Server_Part = NULL; }



$Mail_Server = NULL;

if ($Protocol == 'smtp') {
if ($Mail_Server_Part == 'yandex.ru') {
$Mail_Server = 'smtp.yandex.ru';
}
}
elseif ($Protocol == 'pop3') {
if ($Mail_Server_Part == 'yandex.ru') {
$Mail_Server = 'pop.yandex.ru';
}
}




if (isset($Mail_Server)) {

$Mail_Server_IPs = gethostbynamel($Mail_Server);
if ($Mail_Server_IPs) {

$Mail_Server_IP_Count = count($Mail_Server_IPs);
if ($Mail_Server_IP_Count > 0) {

$idx = mt_rand(0, $Mail_Server_IP_Count - 1);
$Mail_Server_IP = $Mail_Server_IPs[$idx];

$Was_Error = false;

}
else {
/* ошибка */
}

}
else {
/* ошибка */
}

}
else {
/* ошибка */
}




header("Status: 200 OK");

if (!$Was_Error) {

header('Auth-Status: OK');
header('Auth-Server: ' . $Mail_Server_IP);
header('Auth-Port: ' . $Mail_Server_Port);
header('Auth-User: ' . $User_Name);
header('Auth-Pass: ' . $User_Pass);

}
else {

header('Auth-Status: ' . $Error_Str);
header('Auth-Wait: 3');

}


ob_end_flush();


?>
-----------------------------------------------------




По POP3 почта принимается нормально, а отправка по SMTP не работает.

Bat пишет:
-----------------------------------------------------
FETCH - Соединение с сервером прервано (последние переданные команды: "EHLO localhost", "MAIL FROM:<..............@yandex.ru> SIZE=468")
-----------------------------------------------------

В error.log появляется такая строчка:
-----------------------------------------------------
[error] 8324#11272: *6 upstream sent invalid response: "502 5.5.2 Syntax error, command unrecognized." while reading response from upstream, client: 127.0.0.1, server: 0.0.0.0:25, login: "...........@yandex.ru", upstream: 213.180.204.38:25
-----------------------------------------------------


Подскажите пожалуйста как правильно настроить SMTP-proxy
Subject Author Posted

Настройка mail-proxy

MKG October 18, 2012 04:23AM

Re: Настройка mail-proxy

Maxim Dounin October 18, 2012 05:18AM

Re: Настройка mail-proxy

MKG October 18, 2012 05:37AM

Re: Настройка mail-proxy

kav October 18, 2012 05:42AM

Re: Настройка mail-proxy

MKG October 18, 2012 06:18AM

Re: Настройка mail-proxy

Maxim Dounin October 18, 2012 05:46AM

Re: Настройка mail-proxy

MKG October 18, 2012 06:22AM

Re: Настройка mail-proxy

MKG October 19, 2012 10:45AM

Re: Настройка mail-proxy

Maxim Dounin October 24, 2012 11:50AM

Re: Настройка mail-proxy

MKG November 02, 2012 01:24AM

Re: Настройка mail-proxy

Илья Шипицин October 18, 2012 05:48AM

Re: Настройка mail-proxy

MKG October 18, 2012 06:29AM

Re: Настройка mail-proxy

Илья Шипицин October 18, 2012 12:18PM

Re: Настройка mail-proxy

Andrey Repin October 18, 2012 02:06PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 177
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready