{"id":252731,"date":"2015-03-10T14:55:02","date_gmt":"2015-03-10T10:55:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=252731"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=252731","title":{"rendered":"Sendmail-\u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0430 \u0434\u043b\u044f PHP \u0438 \u043d\u0430 PHP"},"content":{"rendered":"<p> \t\t\t\u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u0435\u0431\u0441\u0435\u0440\u0432\u0435\u0440, \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0441\u044c \u0441 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c \u043e \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0435 \u0434\u043b\u044f Sendmail.<\/p>\n<p>  \u0415\u0441\u0442\u044c \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f Windows: <b>fake sendmail for windows<\/b> (sendmail.exe) <a href=\"http:\/\/glob.com.au\/sendmail\/\">http:\/\/glob.com.au\/sendmail\/<\/a><br \/>  \u041d\u0430 \u0445\u0430\u0431\u0440\u0435 \u0435\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044f \u043e\u0431 \u044d\u0442\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438: <b>PHP mail \u043f\u043e\u0434 Windows<\/b> <a href=\"http:\/\/habrahabr.ru\/post\/26518\/\">http:\/\/habrahabr.ru\/post\/26518\/<\/a><br \/>  \u0415\u0449\u0451 \u043e\u0434\u043d\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0434 Windows: <b>Test Mail Server Tool<\/b> <a href=\"http:\/\/www.toolheap.com\/test-mail-server-tool\/\">http:\/\/www.toolheap.com\/test-mail-server-tool\/<\/a><br \/>  \u0422\u0430\u043a \u0436\u0435 \u0435\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044f \u0434\u043b\u044f \u043b\u0438\u043d\u0443\u043a\u0441\u043e\u0438\u0434\u043e\u0432: <b>Sendmail-\u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0430 \u0434\u043b\u044f Linux<\/b> <a href=\"http:\/\/habrahabr.ru\/post\/49665\/\">http:\/\/habrahabr.ru\/post\/49665\/<\/a><\/p>\n<p>  \u041b\u0438\u0447\u043d\u043e \u043c\u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c PHP, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438 \u043f\u043e\u0439\u0434\u0451\u0442 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435.<br \/>  <a name=\"habracut\"><\/a><br \/>  <b>\u0418\u0437 \u043f\u043b\u044e\u0441\u043e\u0432:<\/b>  <\/p>\n<ul>\n<li>\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432<\/li>\n<li>\u041a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f OS \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d PHP<\/li>\n<li>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430 \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0438<\/li>\n<li>\u0412\u0441\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 PHP<\/li>\n<li>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u0444\u0430\u0439\u043b\u0435<\/li>\n<\/ul>\n<p>  <b>\u0418\u0437 \u043c\u0438\u043d\u0443\u0441\u043e\u0432:<\/b>  <\/p>\n<ul>\n<li>\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0447\u0442\u043e\u0432\u044b\u0439 \u044f\u0449\u0438\u043a<\/li>\n<\/ul>\n<p>  <b>\u0421\u043f\u0438\u0441\u043e\u043a \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0438:<\/b>  <\/p>\n<ul>\n<li><b>&#8212;dir &lt;\u041f\u0443\u0442\u044c \u043a \u043f\u0430\u043f\u043a\u0435&gt;<\/b> \u2014 \u041f\u0430\u043f\u043a\u0430 \u0434\u043b\u044f \u0444\u0430\u0439\u043b\u043e\u0432<\/li>\n<li><b>&#8212;file &lt;\u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430&gt;<\/b> \u2014 \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u043e\u0431\u0449\u0435\u043c \u0444\u0430\u0439\u043b\u0435<\/li>\n<li><b>&#8212;prepend<\/b> \u2014 \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u043e\u0431\u0449\u0435\u0433\u043e \u0444\u0430\u0439\u043b\u0430<\/li>\n<li><b>&#8212;open<\/b> \u2014 \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 Notepad<\/li>\n<\/ul>\n<p>  <b>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f PHP.INI \u0444\u0430\u0439\u043b\u0430:<\/b><\/p>\n<pre><code class=\"bash\">[mail function] ;SMTP = localhost ;smtp_port = 25 ;sendmail_from = me@example.com sendmail_path = &quot;php.exe C:\\sendmail.php --dir C:\\mail --open&quot; <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u0443\u0442\u044c \u043a php.exe \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043d \u0432 PATH, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 PHP.INI \u0438\u043d\u0430\u0447\u0435 \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c php.exe \u043d\u0430 &lt;\u041f\u0443\u0442\u044c \u043a \u043f\u0430\u043f\u043a\u0435 \u0441 PHP&gt;\\php.exe<\/p>\n<pre><code class=\"bash\">sendmail_path = &quot;C:\\server\\bin\\php\\php.exe C:\\sendmail.php --dir C:\\mail --open&quot; <\/code><\/pre>\n<p>  \u041d\u0430 \u043b\u0438\u043d\u0443\u043a\u0441 \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443, \u043d\u0435 \u0437\u0430\u0431\u044b\u0432 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u044b\u043c: <u>chmod 755 sendmail.php<\/u>  <\/p>\n<pre><code class=\"bash\">sendmail_path = &quot;\/home\/someuser\/sendmail.php --dir \/tmp\/mail&quot; <\/code><\/pre>\n<p>  <b>\u0421\u0430\u043c sendmail.php \u0441\u043a\u0440\u0438\u043f\u0442:<\/b><\/p>\n<pre><code class=\"php\">#!\/usr\/local\/bin\/php  &lt;?php \/*  PHP.INI *  [mail function] *  ;SMTP = localhost *  ;smtp_port = 25 *  ;sendmail_from = me@example.com *  sendmail_path = php.exe sendmail.php --dir C:\\mail --open *\/  $is_windows = substr(php_uname(), 0, 7) === &quot;Windows&quot;; $is_open = (empty($argv) || !in_array('--open', $argv)) ? FALSE : TRUE; $is_prepend = (empty($argv) || !in_array('--prepend', $argv)) ? FALSE : TRUE; $is_onefile = (empty($argv) || !in_array('--file', $argv)) ? FALSE : TRUE; $mail_dir = get_next_arg('--dir', sys_get_temp_dir().'\/mail'); $file_name = get_next_arg('--file', mkname()); $file_path = $mail_dir.'\/'.$file_name;  if( !is_dir( $mail_dir ) ) {   mkdir( $mail_dir, 0777, TRUE );   if( !is_dir( $mail_dir ) ) {     die('Mail folder ['.$mail_dir.'] not created');   } }  $stream = $is_onefile ? PHP_EOL . str_repeat(&quot;-=&quot;, 10) . date('Y-m-d H:i:s') . str_repeat(&quot;-=&quot;, 10) . PHP_EOL : ''; $fp = fopen('php:\/\/stdin','r'); if (!$fp) {   die('Unable to open stdin for input'); } while($t=fread($fp,2048)) {   if( $t===chr(0) ) {     break;   }   $stream .= ($is_windows ? str_replace(&quot;\\n&quot;, PHP_EOL, $t) : $t); } fclose($fp);  if($is_prepend && file_exists($file_path)) {   $file_contents = file_get_contents($file_path);   $stream .= $file_contents; }   file_put_contents($file_path, $stream, $is_prepend ? 0 : FILE_APPEND);  if ($is_open && $is_windows){    pclose(popen(&quot;start \/B notepad &quot;. $file_path, &quot;r&quot;));   }  function mkname($i=0) {   global $mail_dir;   $fn = 'mail_'.date('Y-m-d_H-i-s_').$i.'.txt';   return file_exists($mail_dir.'\/'.$fn) ? mkname(++$i) : $fn; }  function get_next_arg($key, $default = NULL) {   global $argv;   if(empty($argv) || !in_array($key, $argv) || empty($argv[array_search($key, $argv, TRUE)+1])) {     return $default;   } else {     return $argv[array_search($key, $argv, TRUE)+1];   } } <\/code><\/pre>\n<p>  \u0411\u0443\u0434\u0443 \u0440\u0430\u0434, \u0435\u0441\u043b\u0438 \u0412\u0430\u043c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c. \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/252607\/\"> http:\/\/habrahabr.ru\/post\/252607\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p> \t\t\t\u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u0435\u0431\u0441\u0435\u0440\u0432\u0435\u0440, \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0441\u044c \u0441 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c \u043e \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0435 \u0434\u043b\u044f Sendmail.<\/p>\n<p>  \u0415\u0441\u0442\u044c \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f Windows: <b>fake sendmail for windows<\/b> (sendmail.exe) <a href=\"http:\/\/glob.com.au\/sendmail\/\">http:\/\/glob.com.au\/sendmail\/<\/a><br \/>  \u041d\u0430 \u0445\u0430\u0431\u0440\u0435 \u0435\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044f \u043e\u0431 \u044d\u0442\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438: <b>PHP mail \u043f\u043e\u0434 Windows<\/b> <a href=\"http:\/\/habrahabr.ru\/post\/26518\/\">http:\/\/habrahabr.ru\/post\/26518\/<\/a><br \/>  \u0415\u0449\u0451 \u043e\u0434\u043d\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0434 Windows: <b>Test Mail Server Tool<\/b> <a href=\"http:\/\/www.toolheap.com\/test-mail-server-tool\/\">http:\/\/www.toolheap.com\/test-mail-server-tool\/<\/a><br \/>  \u0422\u0430\u043a \u0436\u0435 \u0435\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044f \u0434\u043b\u044f \u043b\u0438\u043d\u0443\u043a\u0441\u043e\u0438\u0434\u043e\u0432: <b>Sendmail-\u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0430 \u0434\u043b\u044f Linux<\/b> <a href=\"http:\/\/habrahabr.ru\/post\/49665\/\">http:\/\/habrahabr.ru\/post\/49665\/<\/a><\/p>\n<p>  \u041b\u0438\u0447\u043d\u043e \u043c\u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c PHP, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438 \u043f\u043e\u0439\u0434\u0451\u0442 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-252731","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/252731","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=252731"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/252731\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=252731"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=252731"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=252731"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}