{"id":312,"date":"2014-03-28T14:49:21","date_gmt":"2014-03-28T10:49:21","guid":{"rendered":"http:\/\/blog.mgvmi-hipl.ru\/?p=312"},"modified":"2014-03-28T14:49:21","modified_gmt":"2014-03-28T10:49:21","slug":"%d0%9f%d0%b5%d1%80%d0%b5%d0%bd%d0%be%d1%81-%d0%bf%d0%b8%d1%81%d0%b5%d0%bc-%d0%b8%d0%b7-%d0%be%d0%b4%d0%bd%d0%be%d0%b3%d0%be-%d1%8f%d1%89%d0%b8%d0%ba%d0%b0-%d0%b2-%d0%b4%d1%80%d1%83%d0%b3%d0%be%d0%b9","status":"publish","type":"post","link":"https:\/\/blog.5flor.ru\/?p=312","title":{"rendered":"\u041f\u0435\u0440\u0435\u043d\u043e\u0441 \u043f\u0438\u0441\u0435\u043c \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u044f\u0449\u0438\u043a\u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439"},"content":{"rendered":"<h3 itemprop=\"name\">\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0447\u0442\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ImapSync<\/h3>\n<div>\u00a0<\/div>\n<div id=\"post-body-157420556029801032\" itemprop=\"description articleBody\">\n<div dir=\"ltr\">\u041f\u0440\u0438 \u0437\u0430\u043c\u0435\u043d\u0435 \u043f\u043e\u0447\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0443 \u043f\u043e\u0447\u0442\u044b \u0441\u043e \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439. \u0415\u0441\u043b\u0438 \u043e\u0431\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043f\u043e\u0434 Linux, \u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0435\u0442, \u0431\u0435\u0440\u0435\u043c \u0438 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \/var\/spool\/mail \u043d\u0430 \u043d\u043e\u0432\u0443\u044e \u0436\u0435\u043b\u0435\u0437\u043a\u0443 \u043b\u044e\u0431\u044b\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0438 \u0432\u043f\u0435\u0440\u0435\u0434. \u0410 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0441\u043b\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0435\u0445\u0430\u0442\u044c \u0441 Microsoft Exchange \u043d\u0430 Exim, \u0438\u043b\u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442?<\/p>\n<p>\u0422\u0443\u0442 \u043d\u0430\u043c \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u043f\u043e\u043c\u043e\u0447\u044c ImapSync. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u0430 \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0447\u0442\u043e\u0432\u044b\u0445 \u043f\u0430\u043f\u043e\u043a \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 IMAP.<\/p><\/div>\n<div dir=\"ltr\">\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c:<\/div>\n<div dir=\"ltr\">yum install imapsync<\/div>\n<div dir=\"ltr\">\n\u0414\u043b\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u044f\u0449\u0438\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c:<br \/>\nimapsync &#8212;host1 server1 &#8212;user1 user1 &#8212;password1 password1 &#8212;host2 server2 &#8212;user2 user2 &#8212;password2password2<\/div>\n<div dir=\"ltr\">\u00a0<\/div>\n<div dir=\"ltr\">\u0417\u0434\u0435\u0441\u044c:<\/p>\n<ul>\n<li>server1 &#8212; \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u043e\u0447\u0442\u0443<\/li>\n<li>user1, password1 &#8212; \u0443\u0447\u0435\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0435<\/li>\n<li>server2 &#8212; \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u0447\u0442\u0443<\/li>\n<li>user2, password2 &#8212; \u0443\u0447\u0435\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043f\u0440\u0438\u0435\u043c\u043d\u0438\u043a\u0435<\/li>\n<\/ul>\n<p>\u0418 \u0442\u0430\u043a \u043f\u044f\u0442\u044c\u0434\u0435\u0441\u044f\u0442 \u0440\u0430\u0437. \u041d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f? \u0422\u043e\u0433\u0434\u0430 \u043f\u0438\u0448\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442!<br \/>\n\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c, \u0447\u0442\u043e \u0443\u0447\u0435\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u043e\u0431\u043e\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442, \u0441\u043a\u0440\u0438\u043f\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043f\u0440\u0438\u0435\u043c\u043d\u0438\u043a\u0435, \u0443\u0447\u0435\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043b\u0435\u0436\u0430\u0442 \u0432 \u0431\u0430\u0437\u0435 MySQL, \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Perl.<\/p>\n<blockquote><p>#! \/usr\/bin\/perl<br \/>\n#\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b MySql<br \/>\n$dbuser = &#8216;user&#8217;;<br \/>\n$dbpass = &#8216;password&#8217;;<br \/>\n$db = &#8216;database&#8217;;<br \/>\n$dbhost = &#8216;localhost&#8217;;<br \/>\n$domain = &#8216;domain.ru&#8217;;<br \/>\n#\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b Exchange<br \/>\n$server = &#8216;192.168.0.123&#8217;;<br \/>\n$domain1 = &#8216;domain.local&#8217;;<\/p>\n<p>use DBI;<br \/>\n#\u0421\u043e\u0437\u0434\u0430\u0435\u043c SQL \u0437\u0430\u043f\u0440\u043e\u0441<br \/>\n#login &#8212; \u043b\u043e\u0433\u0438\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0431\u0435\u0437 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0434\u043e\u043c\u0435\u043d\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 vova)<br \/>\n#decrypt &#8212; \u043f\u0430\u0440\u043e\u043b\u044c \u043f\u043e\u0447\u0442\u043e\u0432\u043e\u0433\u043e \u044f\u0449\u0438\u043a\u0430 \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0432\u0438\u0434\u0435<br \/>\n#domain &#8212; \u043f\u043e\u0447\u0442\u043e\u0432\u044b\u0439 \u0434\u043e\u043c\u0435\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (domain.ru)<br \/>\n#status &#8212; \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<br \/>\n$query = &#8216;SELECT login, decrypt FROM users WHERE domain=\\&#187;.$domain.&#8217;\\&#8217; AND status=\\&#8217;1\\&#187;;<br \/>\n#\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<br \/>\n$dbh = DBI-&gt;connect(&#171;DBI:mysql:database=$db;host=$dbhost&#187;,$dbuser, $dbpass) || die print &#171;Can&#8217;t connect&#187;;<br \/>\n#\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c SQL \u0437\u0430\u043f\u0440\u043e\u0441<br \/>\n$sth = $dbh-&gt;prepare(qq{$query});<br \/>\n$sth -&gt; execute;<br \/>\n# \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044e<br \/>\n# \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445<br \/>\n# \u043f\u043e\u043a\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f<br \/>\nwhile (my ($m_user, $m_pass) = $sth-&gt;fetchrow_array())<br \/>\n\u00a0\u00a0 \u00a0 \u00a0 \u00a0{<br \/>\n$user1=$m_user.&#8217;@&#8217;.$domain1;<br \/>\n$user2=$m_user.&#8217;@&#8217;.$domain;<br \/>\n\u00a0\u00a0 \u00a0 \u00a0 #\u0421\u043e\u043e\u0431\u0449\u0430\u0435\u043c, \u043d\u0430\u0434 \u043a\u0430\u043a\u0438\u043c \u044f\u0449\u0438\u043a\u043e\u043c \u0442\u0440\u0443\u0434\u0438\u043c\u0441\u044f \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442<br \/>\n\u00a0\u00a0 \u00a0 \u00a0 \u00a0print &#171;Syncronize mail for &#171;.$user2.&#187;\\n&#187;;<br \/>\n$r_sync=`imapsync &#8212;host1 $server &#8212;user1 $user1 &#8212;password1 $m_pass &#8212;host2 $dbhost &#8212;user2 $user2 &#8212;password2 $m_pass`;<\/p>\n<p>}<br \/>\n$sth-&gt;finish();<br \/>\n$dbh-&gt;disconnect();<br \/>\nexit;<\/p><\/blockquote>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0430\u043f\u043a\u0438 \u0432 \u043f\u043e\u0447\u0442\u043e\u0432\u043e\u043c \u044f\u0449\u0438\u043a\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043b\u044e\u0447 &#8212;exclude, \u0435\u0441\u043b\u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b \u043f\u0438\u0441\u044c\u043c\u0430 \u0441\u0442\u0430\u0440\u0448\u0435 N \u0434\u043d\u0435\u0439, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c &#8212;maxage. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440<\/p>\n<blockquote><p>$r_sync=`imapsync &#8212;host1 $server &#8212;user1 $user1 &#8212;password1 $m_pass <b>&#8212;exclude &#8216;spam&#8217; &#8212;maxage 10<\/b> &#8212;host2 $dbhost &#8212;user2 $user2 &#8212;password2 $m_pass`;<\/p><\/blockquote>\n<p>\u00a0\u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0430\u043f\u043a\u0438 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c spam \u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0440\u0448\u0435 10 \u0434\u043d\u0435\u0439.<br \/>\n\u0418\u043c\u0435\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u044e\u0447\u0438\u043a\u043e\u0432, \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0441\u043c\u043e\u0442\u0440\u0438\u043c<\/p>\n<blockquote><p>perldoc imapsync<\/p><\/blockquote>\n<\/div>\n<div>\u00a0<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0447\u0442\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ImapSync \u00a0 \u041f\u0440\u0438 \u0437\u0430\u043c\u0435\u043d\u0435 \u043f\u043e\u0447\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0443 \u043f\u043e\u0447\u0442\u044b \u0441\u043e \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439. \u0415\u0441\u043b\u0438 \u043e\u0431\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043f\u043e\u0434 Linux, \u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0435\u0442, \u0431\u0435\u0440\u0435\u043c \u0438 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \/var\/spool\/mail \u043d\u0430 \u043d\u043e\u0432\u0443\u044e \u0436\u0435\u043b\u0435\u0437\u043a\u0443 \u043b\u044e\u0431\u044b\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c &hellip; <a href=\"https:\/\/blog.5flor.ru\/?p=312\">\u0427\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043b\u0435\u0435 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,8,5],"tags":[],"class_list":["post-312","post","type-post","status-publish","format-standard","hentry","category-linux","category-mail","category-postfix"],"_links":{"self":[{"href":"https:\/\/blog.5flor.ru\/index.php?rest_route=\/wp\/v2\/posts\/312"}],"collection":[{"href":"https:\/\/blog.5flor.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.5flor.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.5flor.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.5flor.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=312"}],"version-history":[{"count":0,"href":"https:\/\/blog.5flor.ru\/index.php?rest_route=\/wp\/v2\/posts\/312\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.5flor.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.5flor.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.5flor.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}