{"id":852,"date":"2011-06-03T20:21:16","date_gmt":"2011-06-03T11:21:16","guid":{"rendered":"http:\/\/wp.kaz.bz\/tech\/?p=852"},"modified":"2011-06-03T20:21:16","modified_gmt":"2011-06-03T11:21:16","slug":"postfix-dovecot-%e3%81%a7%e4%bb%ae%e6%83%b3%e3%83%a1%e3%83%bc%e3%83%ab%e3%83%9c%e3%83%83%e3%82%af%e3%82%b9%e3%82%92%e4%bd%9c%e6%88%90%e3%81%99%e3%82%8b%e3%82%b9%e3%82%af%e3%83%aa%e3%83%97%e3%83%88","status":"publish","type":"post","link":"https:\/\/wp.kaz.bz\/tech\/2011\/06\/03\/852.html","title":{"rendered":"postfix + dovecot \u3067\u4eee\u60f3\u30e1\u30fc\u30eb\u30dc\u30c3\u30af\u30b9\u3092\u4f5c\u6210\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u3002"},"content":{"rendered":"<p>postfix + dovecot \u3067\u4eee\u60f3\u30e1\u30fc\u30eb\u30dc\u30c3\u30af\u30b9\u3092\u4f5c\u6210\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u3002<br \/>\n\u30c6\u30b9\u30c8\u9001\u4fe1\uff0b\u53d7\u4fe1\u4ed8\u3002<br \/>\n\u305f\u3060\u3057\u30a8\u30e9\u30fc\u51e6\u7406\u306f\u307b\u3068\u3093\u3069\u306a\u3044\u3002\u3002<\/p>\n<p>\u4e8b\u524d\u306b\u4e0b\u8a18\u306e\u3088\u3046\u306a\u8a2d\u5b9a\u3092\u3057\u3066\u304a\u304f\u3002<\/p>\n<p>\uff3b\/etc\/postfix\/main.cf\uff3d<br \/>\n\u4e0b\u8a18\u3092\u8ffd\u8a18<\/p>\n<pre class=\"brush:\">\r\nvirtual_mailbox_domains = example.com\r\nvirtual_mailbox_base = \/var\/mail\/vhosts\r\nvirtual_mailbox_maps = hash:\/etc\/postfix\/vmailbox\r\nvirtual_minimum_uid = 100\r\nvirtual_uid_maps = static:5000\r\nvirtual_gid_maps = static:5000\r\n<\/pre>\n<p>\uff3b\/etc\/dovecot.conf\uff3d<br \/>\n\u4e0b\u8a18\u306e\u3088\u3046\u306b\u306a\u308b\u3088\u3046\u306b\u8a2d\u5b9a<\/p>\n<pre class=\"brush:\">\r\nauth default {\r\n\u3000passdb pam {\r\n\u3000}\r\n\u3000passdb passwd-file {\r\n\u3000\u3000args = \/var\/mail\/pw\r\n\u3000}\r\n\u3000userdb passwd {\r\n\u3000}\r\n\u3000userdb passwd-file {\r\n\u3000\u3000args = \/var\/mail\/pw\r\n\u3000}\r\n}\r\n<\/pre>\n<p>\u3067\u3001\u672c\u984c\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3002<\/p>\n<p>\u30b9\u30af\u30ea\u30d7\u30c8\u540d \u4f5c\u6210\u3059\u308b\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\uff08@\u524d\uff09 \u30d1\u30b9\u30ef\u30fc\u30c9<\/p>\n<p>\u306e\u5f62\u5f0f\u3067\u5b9f\u884c\u3067\u3059\u3002<\/p>\n<pre class=\"brush:shell\">\r\n#! \/bin\/sh\r\n\r\nDOMAIN=example.com\r\nUSERNAME=$1\r\nUSERMAIL=$1@${DOMAIN}\r\nPW=$2\r\n\r\n\r\nTMPFILE=\/tmp\/dovcotpwcreatetmpfile\r\nVMAILBOX=\/etc\/postfix\/vmailbox\r\nPWFILE=\/var\/mail\/pw\r\n\r\n\r\ncreate_mail_account(){\r\n\r\n        # \u30e1\u30fc\u30eb\u30dc\u30c3\u30af\u30b9\u8a2d\u5b9a\r\n        echo \"${USERMAIL}    ${DOMAIN}\/${USERNAME}\/Maildir\/\" >> ${VMAILBOX}\r\n\r\n        # POP\u30e6\u30fc\u30b6\u4f5c\u6210\r\n        echo -n ${USERMAIL}\":\" > ${TMPFILE}\r\n\r\n        expect -c \"\r\n        spawn  dovecotpw -s CRAM-MD5\r\n        expect \\\"Enter new password:\\\"\r\n        send   \\\"${PW}\\n\\\"\r\n        expect \\\"Retype new password:\\\"\r\n        send   \\\"${PW}\\n\\\"\r\n        interact\r\n        \" | tail -1 | tr -d \"\\r\\n\" >> ${TMPFILE} \r\n\r\n        echo \":5000:5000::\/var\/mail\/vhosts\/${DOMAIN}\/${USERNAME}\/\" >> ${TMPFILE}\r\n\r\n        cat ${TMPFILE} >> ${PWFILE}\r\n        rm -rf ${TMPFILE}\r\n\r\n        postmap ${VMAILBOX}\r\n\r\n        echo \"${USERMAIL} \u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002\"\r\n}\r\n\r\nsend_test_mail(){\r\n        echo \"\u30c6\u30b9\u30c8\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3057\u307e\u3059\u3002\"\r\n        expect -c \"\r\n        spawn telnet localhost smtp\r\n        expect \\\"220 *\\\"\r\n        send   \\\"helo localhost\\n\\\"\r\n        expect \\\"250 *\\\"\r\n        send   \\\"mail from: localhost\\n\\\"\r\n        expect \\\"250 *\\\"\r\n        send   \\\"rcpt to:${USERMAIL}\\n\\\"\r\n        expect \\\"250 *\\\"\r\n        send   \\\"data\\n\\\"\r\n        expect \\\"354 *\\\"\r\n        send   \\\"Subject: Test Mail\\n\\nMail.\\n.\\n\\\"\r\n        expect \\\"250 *\\\"\r\n        send   \\\"quit\\n\\\"\r\n        expect \\\"221 *\\\"\r\n        interact\r\n        \"\r\n}\r\n\r\npop_test(){\r\n        echo \"POP\u30c6\u30b9\u30c8\u3092\u3057\u307e\u3059\u3002\"\r\n        expect -c \"\r\n        set timeout 10\r\n        spawn telnet localhost pop3\r\n        expect \\\"+OK*\\\"\r\n        send   \\\"user ${USERMAIL}\\n\\\"\r\n        expect \\\"+OK*\\\"\r\n        send   \\\"pass ${PW}\\n\\\"\r\n        expect \\\"+OK*\\\"\r\n        send   \\\"list\\n\\\"\r\n        expect \\\".*\\\"\r\n        send   \\\"retr 1\\n\\\"\r\n        expect \\\".*\\\"\r\n        send   \\\"quit\\n\\\"\r\n        expect \\\"+OK*\\\"\r\n        interact\r\n        \"\r\n}\r\n\r\nif [ -z \"$( grep \"${USERMAIL}\" ${VMAILBOX} )\" ] ; then\r\n    if [ -z \"$( grep \"${USERMAIL}\" ${PWFILE} )\" ] ;then\r\n        create_mail_account \\\r\n        && send_test_mail \\\r\n        && pop_test\r\n    else\r\n        echo \"POP\u30d1\u30b9\u30ef\u30fc\u30c9\u30d5\u30a1\u30a4\u30eb\u306b\u65e2\u306b ${USERMAIL} \u306e\u8a2d\u5b9a\u304c\u3042\u308a\u307e\u3059\u3002\"\r\n        echo \"\u51e6\u7406\u3092\u4e2d\u6b62\u3057\u307e\u3059\u3002\"\r\n    fi\r\nelse\r\n    echo \"\u4eee\u60f3\u30e1\u30fc\u30eb\u30dc\u30c3\u30af\u30b9\u30d5\u30a1\u30a4\u30eb\u306b\u65e2\u306b ${USERMAIL} \u306e\u8a2d\u5b9a\u304c\u3042\u308a\u307e\u3059\u3002\"\r\n    echo \"\u51e6\u7406\u3092\u4e2d\u6b62\u3057\u307e\u3059\u3002\"\r\nfi\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>postfix + dovecot \u3067\u4eee\u60f3\u30e1\u30fc\u30eb\u30dc\u30c3\u30af\u30b9\u3092\u4f5c\u6210\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u3002 \u30c6\u30b9\u30c8\u9001\u4fe1\uff0b\u53d7\u4fe1\u4ed8\u3002 \u305f\u3060\u3057\u30a8\u30e9\u30fc\u51e6\u7406\u306f\u307b\u3068\u3093\u3069\u306a\u3044\u3002\u3002 \u4e8b\u524d\u306b\u4e0b\u8a18\u306e\u3088\u3046\u306a\u8a2d\u5b9a\u3092\u3057\u3066\u304a\u304f\u3002 \uff3b\/etc\/postfix\/main.cf\uff3d  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[56,8],"tags":[],"class_list":["post-852","post","type-post","status-publish","format-standard","hentry","category-postfix_dovecot","category-shellscript"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":759,"url":"https:\/\/wp.kaz.bz\/tech\/2011\/03\/31\/759.html","url_meta":{"origin":852,"position":0},"title":"qmail\u3067\u30bb\u30ab\u30f3\u30c0\u30ea\u30e1\u30fc\u30eb\u30b5\u30fc\u30d0\u3092\u7acb\u3066\u308b\u969b\u306e\u8a2d\u5b9a\u3002","author":"kaz. Suenaga","date":"2011\/03\/31","format":false,"excerpt":"qmail \uff08 net-qmail \u306a\u3069 qmail \u3092\u30d9\u30fc\u30b9\u306b\u3057\u3066\u3044\u308b\u30e1\u30fc\u30eb\u30b5\u30fc\u30d0 \uff09\u3092\u5229\u7528\u3057\u3066\u30bb\u2026","rel":"","context":"qmail \/ vpopmail","block_context":{"text":"qmail \/ vpopmail","link":"https:\/\/wp.kaz.bz\/tech\/category\/servers\/djb\/qmail-vpopmail"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4,"url":"https:\/\/wp.kaz.bz\/tech\/2009\/11\/11\/4.html","url_meta":{"origin":852,"position":1},"title":"qmail + vpopmail\u74b0\u5883\u3078\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb","author":"kaz. Suenaga","date":"2009\/11\/11","format":false,"excerpt":"qmail + vpopmail \u306e\u74b0\u5883\u306bmailman \u3092\u30bd\u30fc\u30b9\u304b\u3089\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u969b\u306e\u624b\u9806\u3002 v\u2026","rel":"","context":"mailman","block_context":{"text":"mailman","link":"https:\/\/wp.kaz.bz\/tech\/category\/servers\/mailman"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":634,"url":"https:\/\/wp.kaz.bz\/tech\/2011\/02\/03\/634.html","url_meta":{"origin":852,"position":2},"title":"daemontools + ucspi-tcp + djbdns(dnscache) + netqmail =","author":"kaz. Suenaga","date":"2011\/02\/03","format":false,"excerpt":"\u4e00\u6c17\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u6c7a\u3081\u3046\u3061\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3059\u3002 \/usr\/local\/src\/djb \u3068\u304b\u306b ins\u2026","rel":"","context":"DJB","block_context":{"text":"DJB","link":"https:\/\/wp.kaz.bz\/tech\/category\/servers\/djb"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2785,"url":"https:\/\/wp.kaz.bz\/tech\/2024\/01\/29\/2785.html","url_meta":{"origin":852,"position":3},"title":"\uff08\u30e1\u30e2\uff09 CentOS \/ Almalinux \u7cfb\u3067\u306e\u9001\u4fe1\u8005\u30ac\u30a4\u30c9\u30e9\u30a4\u30f3\u5bfe\u5fdc\uff08DKIM\uff09","author":"kaz. Suenaga","date":"2024\/01\/29","format":false,"excerpt":"Google \u9001\u4fe1\u8005\u30ac\u30a4\u30c9\u30e9\u30a4\u30f3\u3078\u306e\u4e3b\u306a\u5bfe\u5fdc Google: \u30e1\u30fc\u30eb\u9001\u4fe1\u8005\u306e\u30ac\u30a4\u30c9\u30e9\u30a4\u30f3 \u5bfe\u8c61\u3068\u306a\u308b\u2026","rel":"","context":"AlmaLinux","block_context":{"text":"AlmaLinux","link":"https:\/\/wp.kaz.bz\/tech\/category\/lin\/almalinux"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":39,"url":"https:\/\/wp.kaz.bz\/tech\/2008\/06\/18\/39.html","url_meta":{"origin":852,"position":4},"title":"vpopmail\u306e\u5168\u30c9\u30e1\u30a4\u30f3\u30fb\u5168\u30e1\u30fc\u30eb\u30dc\u30c3\u30af\u30b9\u306e\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3002","author":"kaz. Suenaga","date":"2008\/06\/18","format":false,"excerpt":"vpopmail\u306e\u5168\u30d0\u30fc\u30c1\u30e3\u30eb\u30c9\u30e1\u30a4\u30f3\u30fb\u5168\u30e1\u30fc\u30eb\u30dc\u30c3\u30af\u30b9\u306e\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3092\u76ee\u7684\u3068\u3057\u305f\u30b9\u30af\u30ea\u30d7\u30c8\u3002 va\u2026","rel":"","context":"qmail \/ vpopmail","block_context":{"text":"qmail \/ vpopmail","link":"https:\/\/wp.kaz.bz\/tech\/category\/servers\/djb\/qmail-vpopmail"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2035,"url":"https:\/\/wp.kaz.bz\/tech\/2015\/05\/09\/2035.html","url_meta":{"origin":852,"position":5},"title":"CentOS 7 \u3067 niltalk + httpd \u3002","author":"kaz. Suenaga","date":"2015\/05\/09","format":false,"excerpt":"\u30e1\u30e2\u3002 MOONGIFT\u3055\u3093\u306e\u8a18\u4e8b http:\/\/moongift.jp\/2015\/05\/nilta\u2026","rel":"","context":"\u305d\u306e\u4ed6","block_context":{"text":"\u305d\u306e\u4ed6","link":"https:\/\/wp.kaz.bz\/tech\/category\/servers\/%e3%81%9d%e3%81%ae%e4%bb%96"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/wp.kaz.bz\/tech\/wp-json\/wp\/v2\/posts\/852","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.kaz.bz\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.kaz.bz\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.kaz.bz\/tech\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.kaz.bz\/tech\/wp-json\/wp\/v2\/comments?post=852"}],"version-history":[{"count":0,"href":"https:\/\/wp.kaz.bz\/tech\/wp-json\/wp\/v2\/posts\/852\/revisions"}],"wp:attachment":[{"href":"https:\/\/wp.kaz.bz\/tech\/wp-json\/wp\/v2\/media?parent=852"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.kaz.bz\/tech\/wp-json\/wp\/v2\/categories?post=852"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.kaz.bz\/tech\/wp-json\/wp\/v2\/tags?post=852"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}