{"id":18804,"date":"2015-03-18T06:58:56","date_gmt":"2015-03-17T22:58:56","guid":{"rendered":"https:\/\/2blog.ilc.edu.tw\/25793\/2015\/03\/18\/debian-linux-%e4%bd%bf%e7%94%a8-gmail-%e4%be%86%e5%af%84%e9%80%81-server-%e7%9a%84-log-%e6%aa%94\/"},"modified":"2021-03-18T17:24:21","modified_gmt":"2021-03-18T09:24:21","slug":"debian-linux-%e4%bd%bf%e7%94%a8-gmail-%e4%be%86%e5%af%84%e9%80%81-server-%e7%9a%84-log-%e6%aa%94","status":"publish","type":"post","link":"https:\/\/2blog.ilc.edu.tw\/25793\/2015\/03\/18\/debian-linux-%e4%bd%bf%e7%94%a8-gmail-%e4%be%86%e5%af%84%e9%80%81-server-%e7%9a%84-log-%e6%aa%94\/","title":{"rendered":"Debian Linux &#8211; \u4f7f\u7528 gmail \u4f86\u5bc4\u9001 Server \u7684 log \u6a94"},"content":{"rendered":"<p>\u7e23\u7db2\u53ef\u80fd\u56e0\u70ba\u8cc7\u5b89\u7684\u56e0\u7d20\uff0c\u6240\u4ee5\u9810\u8a2d\u4e26\u4e0d\u5141\u8a31 Server\u00a0\u53ef\u4ee5\u5916\u9001\u4fe1\u4ef6\uff0c\u5982\u679c\u8981\u6253\u958b\u9019\u4e00\u9805\u529f\u80fd\uff0c\u8981\u8207\u8cc7\u7db2\u806f\u7e6b\uff0c\u6709\u4e9b\u9ebb\u7169\uff0c\u56e0\u70ba\u5b78\u6821\u7684\u9019\u4e9b Server\uff0c\u4e26\u6c92\u6709\u64d4\u4efb Mail Server\u00a0\u7684\u5de5\u4f5c\uff0c\u53ea\u662f\u7d14\u7cb9\u8981\u628a\u7cfb\u7d71\u7684 log\u00a0\u6a94\u6848\u5f59\u6574\u5230\u5916\u90e8\u7684\u4fe1\u7bb1\u800c\u5df2\uff0c\u6240\u4ee5\u6539\u7528 Google Mail\u00a0\u4f86\u5916\u9001\u4fe1\u4ef6\u3002<br \/>\u53c3\u8003\u7db2\u9801\uff1a<br \/><a href=\"http:\/\/iori.tw\/%E9%80%8F%E9%81%8Essmtp%E8%88%87gmail%E5%B8%B3%E6%88%B6%E4%BE%86%E5%81%9Amail%E8%87%AA%E5%8B%95%E9%80%9A%E7%9F%A5-on-centos-5-x\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u900f\u904essmtp\u8207Gmail\u5e33\u6236\u4f86\u505aMail\u81ea\u52d5\u901a\u77e5 on CentOS 5.x | IT\u6c34\u96fb\u5de5-\u54c6\u5566\u80d6\u864e<\/a><br \/><a href=\"https:\/\/blog.gtwang.org\/linux\/linux-send-mail-command-using-ssmtp-and-gmail\/\" target=\"_blank\" rel=\"noopener noreferrer\">Linux \u4f7f\u7528 SSMTP \u8207 GMail \u4ee5\u6307\u4ee4\u6216\u7a0b\u5f0f\u81ea\u52d5\u5bc4\u4fe1\u6559\u5b78 &#8211; G. T. Wang<\/a><\/p>\n<p>1. \u5b89\u88dd ssmtp\u00a0\u53ca logwatch<br \/># <span style=\"color: #ff0000\">apt-get install ssmtp logwatch<\/span><\/p>\n<p>2.\u00a0\u5099\u4efd\u539f\u8a2d\u5b9a\u6a94 <span style=\"color: #0000ff\">\/etc\/ssmtp\/ssmtp.conf<\/span><br \/># <span style=\"color: #ff0000\">cp \/etc\/ssmtp\/ssmtp.conf \/etc\/ssmtp\/ssmtp.conf.$(date +%F)<\/span><br \/>[@more@]<br \/>3.\u00a0\u4fee\u6539\u8a2d\u5b9a\u6a94 <span style=\"color: #0000ff\">\/etc\/ssmtp\/ssmtp.conf<\/span><br \/><span style=\"color: #0000ff\"><span style=\"color: #000000\">#<\/span> <span style=\"color: #ff0000\">vim \/etc\/ssmtp\/ssmtp.conf<br \/><\/span>#root=postmaster<\/span><br \/><span style=\"color: #0000ff\"># The place where the mail goes. The actual machine name is required<\/span><br \/><span style=\"color: #0000ff\"># no MX records are consulted. Commonly mailhosts are named mail.domain.com<\/span><br \/><span style=\"color: #0000ff\"># The example will fit if you are in domain.com and you mailhub is so named.<\/span><br \/><span style=\"color: #0000ff\">mailhub=smtp.gmail.com:587<\/span><br \/><span style=\"color: #0000ff\"># Where will the mail seem to come from?<\/span><br \/><span style=\"color: #0000ff\">#rewriteDomain=y<\/span><br \/><span style=\"color: #0000ff\"># The full hostname<\/span><br \/><span style=\"color: #0000ff\">#hostname=root-chroot-copy<\/span><br \/><span style=\"color: #0000ff\"># \u5bc4\u4ef6\u8005\u5e33\u865f<\/span><br \/><span style=\"color: #0000ff\">AuthUser=xxxx@gmail.com<\/span><br \/><span style=\"color: #0000ff\"># \u5bc4\u4ef6\u8005\u5bc6\u78bc<\/span><br \/><span style=\"color: #0000ff\">AuthPass=xxxx<\/span><br \/><span style=\"color: #0000ff\">UseSTARTTLS=YES<\/span><br \/><span style=\"color: #0000ff\">FromLineOverride=yes #enables to use mail -r option<\/p>\n<p><span style=\"color: #000000\"><\/span><\/span>4. <span style=\"color: #0000ff\"><span style=\"color: #000000\">\u66f4\u6539\u6a94\u6848\u6b0a\u9650<br \/># <span style=\"color: #ff0000\">chmod 0600 \/etc\/ssmtp\/ssmtp.conf<br \/><\/span><br \/>5. \u5099\u4efd\u539f\u8a2d\u5b9a\u6a94 <\/span><\/span><span style=\"color: #0000ff\"><span style=\"color: #000000\"><span style=\"color: #0000ff\"><span style=\"color: #000000\"><span style=\"color: #ff0000\"><span style=\"color: #0000ff\">\/usr\/share\/logwatch\/default.conf\/logwatch.conf<\/span><br \/><\/span><\/span><\/span># <span style=\"color: #ff0000\">cp \/usr\/share\/logwatch\/default.conf\/logwatch.conf \/usr\/share\/logwatch\/default.conf\/logwatch.conf.$(date +%F)<\/span><\/span><\/span><\/p>\n<p>6. \u9032\u884c\u4fee\u6539<br \/># <span style=\"color: #ff0000\">sed -i &#8216;s\/MailTo = root\/MailTo = xxxx@gmail.com\/&#8217; <\/span><span style=\"color: #0000ff\"><span style=\"color: #000000\"><span style=\"color: #ff0000\">\/usr\/share\/logwatch\/default.conf\/logwatch.conf<\/span><br \/># <span style=\"color: #ff0000\">sed -i &#8216;s\/MailFrom = Logwatch\/MailFrom = Logwatch@nxi.test.ilc.edu.tw\/&#8217; <\/span><\/span><\/span><span style=\"color: #0000ff\"><span style=\"color: #000000\"><span style=\"color: #ff0000\">\/usr\/share\/logwatch\/default.conf\/logwatch.conf<\/span><br \/># <span style=\"color: #ff0000\">sed -i &#8216;s\/Output = stdout\/Output = mail\/&#8217; <\/span><\/span><\/span><span style=\"color: #0000ff\"><span style=\"color: #000000\"><span style=\"color: #ff0000\">\/usr\/share\/logwatch\/default.conf\/logwatch.conf<\/span><br \/># <span style=\"color: #ff0000\">sed -i &#8216;s\/Detail = Low\/Detail = Med\/&#8217; <\/span><\/span><\/span><span style=\"color: #0000ff\"><span style=\"color: #000000\"><span style=\"color: #ff0000\">\/usr\/share\/logwatch\/default.conf\/logwatch.conf<\/span><\/p>\n<p>7.\u00a0\u57f7\u884c logwatch\u00a0\u6e2c\u8a66\u662f\u5426\u80fd\u6536\u5230\u4fe1\u4ef6<br \/>\u5982\u679c\u6709\u7121\u6cd5\u6536\u5230\u4fe1\u4ef6\uff0c\u53ef\u8981\u555f\u7528\u00a0<span style=\"color: #ff0000\">\u5b89\u5168\u6027\u8f03\u4f4e\u7684\u61c9\u7528\u7a0b\u5f0f\u5b58\u53d6\u6b0a<\/span><br \/><a id=\"res_2911469\" href=\"https:\/\/2blog.ilc.edu.tw\/wp-content\/uploads\/sites\/985\/25793\/25793-2911469.png\"><img decoding=\"async\" src=\"https:\/\/2blog.ilc.edu.tw\/wp-content\/uploads\/sites\/985\/25793\/previews-med\/25793-2911469.png\" border=\"0\" alt=\"\" \/><\/a><\/p>\n<p><\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7e23\u7db2\u53ef\u80fd\u56e0\u70ba\u8cc7\u5b89\u7684\u56e0\u7d20\uff0c\u6240\u4ee5\u9810\u8a2d\u4e26\u4e0d\u5141\u8a31 Server\u00a0\u53ef\u4ee5\u5916\u9001\u4fe1\u4ef6\uff0c\u5982\u679c\u8981\u6253\u958b\u9019\u4e00\u9805\u529f\u80fd\uff0c\u8981\u8207\u8cc7\u7db2\u806f\u7e6b\uff0c\u6709\u4e9b &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/2blog.ilc.edu.tw\/25793\/2015\/03\/18\/debian-linux-%e4%bd%bf%e7%94%a8-gmail-%e4%be%86%e5%af%84%e9%80%81-server-%e7%9a%84-log-%e6%aa%94\/\" class=\"more-link\">\u95b1\u8b80\u5168\u6587<span class=\"screen-reader-text\">\u3008Debian Linux &#8211; \u4f7f\u7528 gmail \u4f86\u5bc4\u9001 Server \u7684 log \u6a94\u3009<\/span><\/a><\/p>\n","protected":false},"author":55,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[179],"tags":[],"class_list":["post-18804","post","type-post","status-publish","format-standard","hentry","category-c-87877"],"meta_key":{"_pingme":["1"],"_encloseme":["1"],"lt_post_id":["552367"]},"_links":{"self":[{"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/posts\/18804"}],"collection":[{"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/users\/55"}],"replies":[{"embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/comments?post=18804"}],"version-history":[{"count":1,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/posts\/18804\/revisions"}],"predecessor-version":[{"id":20403,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/posts\/18804\/revisions\/20403"}],"wp:attachment":[{"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/media?parent=18804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/categories?post=18804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/tags?post=18804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}