{"id":329,"date":"2012-12-19T18:08:32","date_gmt":"2012-12-19T15:08:32","guid":{"rendered":"http:\/\/www.linux-destek.com\/?p=329"},"modified":"2012-12-19T18:08:32","modified_gmt":"2012-12-19T15:08:32","slug":"mail-formlardan-gonderilen-e-maillerin-izlenmesi-ve-kontrolu","status":"publish","type":"post","link":"https:\/\/www.48k.com.tr\/mail-formlardan-gonderilen-e-maillerin-izlenmesi-ve-kontrolu\/","title":{"rendered":"Mail formlardan g\u00f6nderilen e-maillerin izlenmesi ve kontrol\u00fc"},"content":{"rendered":"
Web sayfalar\u0131n\u0131n bir \u00e7o\u011funda mail form kullan\u0131l\u0131yor.Bu scriptlerde bulunabilecek bir a\u00e7\u0131k sunucunuz \u00fczerinden onbinlerce spam g\u00f6nderimine sebep ve sizin karalistelere girmenize sebep olabilir.A\u015fa\u011f\u0131da kurulumu anlat\u0131lan script form maillerden g\u00f6nderilen her mailin logunu yazmakta ve sizin belirtece\u011finiz al\u0131c\u0131 say\u0131s\u0131na g\u00f6re maili engellemektedir.Scriptin bir k\u0131sm\u0131 anonim al\u0131nt\u0131d\u0131r,ilaveler bulunmaktad\u0131r.<\/p>\n
\u00d6ncelikle php beti\u011finin \u00e7al\u0131\u015fmas\u0131 i\u00e7in gerekli paketleri sistemimize kuruyoruz.Redhat,Centos kullan\u0131yorsan\u0131z \u015fu komutla ilgili paketleri kurabilirsiniz;<\/p>\n
yum install php-pear-Auth-SASL.noarch php-pear-Mail.noarch php-pear-Mail-Mime.noarch php-pear-Net-SMTP.noarch php-pear-Net-Socket.noarch<\/p><\/blockquote>\n
Kurulum bittikten sonra a\u015fa\u011f\u0131daki scripti fmmgw.php ad\u0131yla sisteminizde uygun bir yere veya \/usr\/local\/bin alt\u0131na kopyalay\u0131n.<\/p>\n
#!\/usr\/bin\/php
\n<?php
\nini_set(‘include_path’, ‘\/usr\/share\/pear’);
\n\/\/—CONFIG
\n$config = array(
\n‘host’ => ‘localhost’,
\n‘port’ => 25,
\n‘auth’ => FALSE,
\n);
\n$logDir\u00a0\u00a0\u00a0\u00a0\u00a0 = ‘\/var\/log’;
\n$logFile\u00a0\u00a0\u00a0\u00a0 = ‘mail_proxy.log’;
\n$failPrefix\u00a0 = ‘fail_’;
\n$EOL\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 = “\\n”; \/\/ change to \\r\\n if you send broken mail
\n$defaultFrom = ‘”hostadresiniz.alanadiniz.com Webserver” <fmmgw@alanadiniz.com>’;
\n\/\/—END CONFIG<\/p>\nif (!$log = fopen(“{$logDir}\/{$logFile}”, ‘a’)) {
\ndie(“ERROR: cannot open log file!\\n”);
\n}<\/p>\nrequire(‘Mail.php’); \/\/ PEAR::Mail
\nif (PEAR::isError($Mailer = Mail::factory(‘SMTP’, $config))) {
\nfwrite($log, ts() . “Failed to create PEAR::Mail object\\n”);
\nfclose($log);
\ndie();
\n}<\/p>\n\/\/ get headers\/body
\n$stdin = fopen(‘php:\/\/stdin’, ‘r’);
\n$in = ”;
\nwhile (!feof($stdin)) {
\n$in .= fread($stdin, 1024); \/\/ read 1kB at a time
\n}<\/p>\nlist ($headers, $body) = explode(“$EOL$EOL”, $in, 2);<\/p>\n
$recipients = array();
\n$headers = explode($EOL, $headers);
\n$mailHdrs = array();
\n$lastHdr = false;
\n$recipFields = array(‘to’,’cc’,’bcc’);
\nforeach ($headers AS $h) {
\nif (!preg_match(‘\/^[a-z]\/i’, $h)) {
\nif ($lastHdr) {
\n$lastHdr .= “\\n$h”;
\n}
\n\/\/ skip this line, doesn’t start with a letter
\ncontinue;
\n}
\nlist($field, $val) = explode(‘: ‘, $h, 2);
\nif (isset($mailHdrs[$field])) {
\n$mailHdrs[$field] = (array) $mailHdrs[$field];
\n$mailHdrs[$field][] = $val;
\n} else {
\n$mailHdrs[$field] = $val;
\n}
\nif (in_array(strtolower($field), $recipFields)) {
\nif (preg_match_all(‘\/[^ ;,]+@[^ ;,]+\/’, $val, $m)) {
\n$recipients = array_merge($recipients, $m[0]);;
\n}
\n}
\n}
\nif (!isset($mailHdrs[‘From’])) {
\n$mailHdrs[‘From’] = $defaultFrom;
\n}<\/p>\n$recipients = array_unique($recipients); \/\/ remove dupes<\/p>\n
if(count($recipients)>2) die(“HATA”);<\/p>\n
\/\/ send
\nif (PEAR::isError($send = $Mailer->send($recipients, $mailHdrs, $body))) {
\n$fn = uniqid($failPrefix);
\nfile_put_contents(“{$logDir}\/{$fn}”, $in);
\nfwrite($log, ts() .”Error sending mail: $fn (“. $send->getMessage() .”)\\n”);
\n$ret = 1; \/\/ fail
\n} else {
\nfwrite($log, ts() .”Mail sent “. count($recipients) .” recipients.\\n”);
\n$ret = 0; \/\/ success
\n}
\nfclose($log);
\nreturn $ret;<\/p>\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/<\/p>\n
function ts()
\n{
\nreturn ‘[‘. date(‘y.m.d H:i:s’) .’] ‘;
\n}<\/p>\n?><\/p><\/blockquote>\n
Log dosyan\u0131z\u0131 elle olu\u015fturun<\/p>\n
touch \/var\/log\/mail_proxy.log<\/p><\/blockquote>\n
Son olarak php.ini dosyan\u0131zda ilgili alan\u0131 \u015fu \u015fekilde de\u011fi\u015ftirin.<\/p>\n
sed -i -e ‘s:;sendmail_path = \/usr\/sbin\/sendmail -t -i:sendmail_path = \/usr\/local\/bin\/fmmgw.php:g’ php.ini<\/p><\/blockquote>\n
veya nano,vi gibi bir editor ile php.ini dosyan\u0131zda<\/p>\n
sendmail_path<\/p><\/blockquote>\n
sat\u0131r\u0131n\u0131 bulup kar\u015f\u0131s\u0131na<\/p>\n
\/usr\/local\/bin\/fmmgw.php<\/p><\/blockquote>\n
yazarak dosyan\u0131z\u0131 kaydedin.<\/p>\n
Apache web servisini resetleyin.<\/p>\n
G\u00f6nderilen mailleri anl\u0131k izlemek i\u00e7in<\/p>\n
tail -f \/var\/log\/mail_proxy.log<\/p><\/blockquote>\n
yaz\u0131p inceleyebilirsiniz.<\/p>\n","protected":false},"excerpt":{"rendered":"
Web sayfalar\u0131n\u0131n bir \u00e7o\u011funda mail form kullan\u0131l\u0131yor.Bu scriptlerde bulunabilecek bir a\u00e7\u0131k sunucunuz \u00fczerinden onbinlerce spam g\u00f6nderimine sebep ve sizin karalistelere girmenize sebep olabilir.A\u015fa\u011f\u0131da kurulumu anlat\u0131lan script form maillerden g\u00f6nderilen her mailin logunu yazmakta ve sizin belirtece\u011finiz al\u0131c\u0131 say\u0131s\u0131na g\u00f6re maili engellemektedir.Scriptin bir k\u0131sm\u0131 anonim al\u0131nt\u0131d\u0131r,ilaveler bulunmaktad\u0131r. \u00d6ncelikle php beti\u011finin \u00e7al\u0131\u015fmas\u0131 i\u00e7in gerekli paketleri sistemimize kuruyoruz.Redhat,Centos […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[339,312,349,350,291,358],"tags":[351],"class_list":["post-329","post","type-post","status-publish","format-standard","hentry","category-e-posta-kur","category-e-mail-sunuculari","category-linux-server-kurulumu","category-linux-sunucu-kurulumu","category-uncategorized-tr","category-web-sunuculari","tag-linux-sunucu-kurulumu-2"],"_links":{"self":[{"href":"https:\/\/www.48k.com.tr\/wp-json\/wp\/v2\/posts\/329"}],"collection":[{"href":"https:\/\/www.48k.com.tr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.48k.com.tr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.48k.com.tr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.48k.com.tr\/wp-json\/wp\/v2\/comments?post=329"}],"version-history":[{"count":0,"href":"https:\/\/www.48k.com.tr\/wp-json\/wp\/v2\/posts\/329\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.48k.com.tr\/wp-json\/wp\/v2\/media?parent=329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.48k.com.tr\/wp-json\/wp\/v2\/categories?post=329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.48k.com.tr\/wp-json\/wp\/v2\/tags?post=329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}