ホームページ >バックエンド開発 >PHPチュートリアル >PHP プロセスの後置メール コンテンツ_PHP チュートリアル
<ol class="dp-c"> <li class="alt"><span><span>01 <?php </span></span></li> <li><span> </span></li> <li class="alt"><span>02 </span></li> <li><span> </span></li> <li class="alt"><span>03 #入力からすべてのメールコンテンツを読み取ります </span></li> <li><span> </span></li> <li class="alt"> <span>04 </span><span class="vars"> $email</span> <span> = </span><span class="string">""</span><span>; php://stdin"</span> </li>, <li><span>"r </span></li>); <li class="alt"> <span>恐怖</span><span class="vars">(</span><span> $fd</span><span class="func">、1024); </span><span></span><span class="string"> </span><span></span><span class="string">08 }</span> </li> <li><span> </span></li> <li class="alt"> <span>09 fclose(</span><span class="vars">$fd</span><span>); </span> </li> <li><span> </span></li> <li class="alt"><span>10 </span></li> <li><span>11 #すべてのコンテンツを記録、テスト</span></li> <li class="alt"><span> </span></li> <li><span>12 </span></li> file_put_contents<li class="alt"> <span>(</span><span class="func">"/tmp/mail/"</span><span>.time(), </span><span class="string">$email</span><span>); 13 </span><span class="vars"></span><span> </span> </li> <li><span> 14 #メールを処理しています "</span></li>、<li class="alt"><span>$email</span></li>); <li><span></span></li> <li class="alt"><span></span></li>16 <li><span></span></li> <li class="alt"> <span></span><span class="vars">17 </span><span>// 空の変数</span><span class="func"> </span><span></span><span class="string"> </span><span></span><span class="vars">18 </span><span>$ from</span> </li> = <li><span>""</span></li> <li class="alt"><span></span></li> <li><span>20 </span></li>$subject<li class="alt"> <span> ""</span><span class="comment">; </span><span></span>21 </li> <li>$メッセージ<span></span> = </li> <li class="alt"> ""<span></span><span class="vars"></span>22 <span></span>$分割ヘッダー<span class="string"></span> = true; <span></span>24 </li> <li>for<span></span> (</li> <li class="alt">$i<span></span>= 0; <span class="vars"></span>$i<span></span><<span class="string"></span>カウント<span></span>(</li> <li>$i<span></span>++) { </li> <li class="alt"> <span></span><span class="vars"></span><span></span>2 5 <span class="string"></span><span></span> </li> <li> <span> </span>26 </li> <li class="alt"> <span></span><span class="vars"> </span><span></span>27 , <span class="string">"/^件名: (.*)/"</span><span>, </span> </li> $lines<li><span>[</span></li>$i<li class="alt"> <span>], </span><span class="vars">$matches</span><span>)) { </span> </li> <li><span> </span></li> <li class="alt"><span>29 </span></li>$subject<li><span> = </span></li>$matches<li class="alt"> <span>[1] </span><span class="keyword"> </span><span></span><span class="vars"></span>30 } </li> <li><span> </span></li> <li class="alt"> <span>31 </span><span class="keyword">if</span><span> (preg_match(</span><span class="string">"/^From: (.*)/"</span><span>, </span><span class="vars">$lines</span><span>[</span><span class="vars"> $i</span><span>]、</span><span class="vars"> $matches</span><span>)) { </span> </li> <li><span> </span></li> <li class="alt"> <span>32 </span><span class="keyword">if</span><span>(</span><span class="func">strpos</span><span>(</span><span class="vars">$lines</span><span>[ </span><span class="vars">$i</span><span>]、</span><span class="string">"<"</span> <span>)){ </span> </li> <li><span> </span></li> <li class="alt">33 <span></span>//ヘッダー内にも名前が存在します <span class="comment"></span> <span></span> </li> <li> <span></span> </li> <li class="alt">34 <span></span>$data<span class="vars"></span> = <span></span>爆発<span class="func"></span>(<span></span> <<span class="string"></span>,<span></span>$lines<span class="vars"></span>[<span></span>$i<span class="vars"></span>]); <span></span> </li> <li> <span></span> </li> <li class="alt">35 <span></span>$from<span class="vars"></span> = <span></span>substr<span class="func"></span>(trim(<span></span>$data<span class="vars"></span>[1]),0,-1); <span></span> </li> <li> <span></span> </li> <li class="alt">36 }<span></span>else<span class="keyword"></span>{ <span></span> </li> <li> <span></span> </li>37 <li class="alt"> <span>//のみメール </span><span class="comment"> </span><span></span> </li> <li><span></span></li>38 <li class="alt"> <span>$from</span><span class="vars"> = </span><span>$一致</span><span class="vars">[1]; </span><span></span> </li> <li><span></span></li>39 } <li class="alt"><span></span></li> <li> <span></span> </li> <li clas> <p align="left">http://www.bkjia.com/PHPjc/478830.html</p> <div style="display:none;"> <span id="url" itemprop="url">www.bkjia.com</span><span id="indexUrl" itemprop="indexUrl">true</span><span id="isOriginal" itemprop="isOriginal">http://www.bkjia.com/PHPjc/478830.html</span><span id="isBasedOnUrl" itemprop="isBasedOnUrl">技術記事</span><span id="genre" itemprop="genre"> 01?php 02 03#入力からすべてのファイルの内容を取得します 04 $email = ; 05 $fd = fopen ( php://stdin , r ); 06 while (! feof ( $fd )){ 07 $email .= fread ( $fd ,1024); 08} 09fclose( $fd...</span><span id="description" itemprop="description"></span> </div> </li> </ol>