📄 ch09_05.htm
字号:
<?label 9.5. mailx and mail?><html><head><title>mailx and mail (CGI Programming with Perl)</title><link href="../style/style1.css" type="text/css" rel="stylesheet" /><meta name="DC.Creator" content="Scott Guelich, Gunther Birznieks and Shishir Gundavaram" /><meta scheme="MIME" content="text/xml" name="DC.Format" /><meta content="en-US" name="DC.Language" /><meta content="O'Reilly & Associates, Inc." name="DC.Publisher" /><meta scheme="ISBN" name="DC.Source" content="1565924193L" /><meta name="DC.Subject.Keyword" content="stuff" /><meta name="DC.Title" content="CGI Programming with Perl" /><meta content="Text.Monograph" name="DC.Type" /></head><body bgcolor="#ffffff"><img src="gifs/smbanner.gif" alt="Book Home" usemap="#banner-map" border="0" /><map name="banner-map"><area alt="CGI Programming with Perl" href="index.htm" coords="0,0,466,65" shape="rect" /><area alt="Search this book" href="jobjects/fsearch.htm" coords="467,0,514,18" shape="rect" /></map><div class="navbar"><table border="0" width="515"><tr><td width="172" valign="top" align="left"><a href="ch09_04.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td width="171" valign="top" align="center"><a href="index.htm">CGI Programming with Perl</a></td><td width="172" valign="top" align="right"><a href="ch09_06.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr></table></div><hr align="left" width="515" /><h2 class="sect1">9.5. mailx and mail</h2><p><tt class="command">mailx</tt><a name="INDEX-1900" /><a name="INDEX-1901" /> and <tt class="command">mail </tt>areother popular options for sending email. Some people even argue thatthey are more<a name="INDEX-1902" />secure than<tt class="command">sendmail</tt>. It is true that because<tt class="command">sendmail</tt><a name="INDEX-1903" /> is such a large,complicated program, and because it runs as<em class="emphasis">root</em>, it has been the source of a number ofsecurity holes over the years. However, the notion that it is a lesssecure option in CGI scripts is a dubious one. One serious problemwith <tt class="command">mailx</tt> and <tt class="command">mail</tt> is thatthey allow <a name="INDEX-1904" /> <a name="INDEX-1,905" /><a name="INDEX-1906" />tilde escapes: anyline in the body of the message beginning with <tt class="literal">~!</tt>is executed as a command. Many versions do attempt to detect whetherthey are being run by a user on a terminal and disable tilde escapesotherwise, but this is a serious potential risk.</p><p>A second problem with <tt class="command">mailx</tt> and<tt class="command">mail</tt> is that they offer nothing comparable to<tt class="command">sendmail </tt>'s<em class="emphasis">-t</em><a name="INDEX-1907" /> option. Thus, if you want to use<tt class="command">mail</tt>, for example, you must use the<tt class="function">fork</tt><a name="INDEX-1908" /> <a name="INDEX-1,909" /> and <tt class="function">exec</tt> trick wedescribed in the last chapter:</p><blockquote><pre class="code">open MAIL "|-" or exec( "/bin/mail", $email ) or die "Cannot exec mail $!";</pre></blockquote><p>Finally, <tt class="command">mailx</tt> and <tt class="command">mail</tt> alsolack the useful options we discussed with<tt class="command">sendmail</tt>, such as overriding the sender.</p><hr align="left" width="515" /><div class="navbar"><table border="0" width="515"><tr><td width="172" valign="top" align="left"><a href="ch09_04.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td width="171" valign="top" align="center"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0" /></a></td><td width="172" valign="top" align="right"><a href="ch09_06.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr><tr><td width="172" valign="top" align="left">9.4. sendmail</td><td width="171" valign="top" align="center"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0" /></a></td><td width="172" valign="top" align="right">9.6. Perl Mailers</td></tr></table></div><hr align="left" width="515" /><img src="../gifs/navbar.gif" alt="Library Navigation Links" usemap="#library-map" border="0" /><p><font size="-1"><a href="copyrght.htm">Copyright © 2001</a> O'Reilly & Associates. All rights reserved.</font></p><map name="library-map"><area href="../index.htm" coords="1,1,83,102" shape="rect" /><area href="../lnut/index.htm" coords="81,0,152,95" shape="rect" /><area href="../run/index.htm" coords="172,2,252,105" shape="rect" /><area href="../apache/index.htm" coords="238,2,334,95" shape="rect" /><area href="../sql/index.htm" coords="336,0,412,104" shape="rect" /><area href="../dbi/index.htm" coords="415,0,507,101" shape="rect" /><area href="../cgi/index.htm" coords="511,0,601,99" shape="rect" /></map></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -