smtp.html
来自「perl教程」· HTML 代码 · 共 458 行 · 第 1/2 页
HTML
458 行
<dd>
<p>Request a queue run for the DOMAIN given.</p>
</dd>
</li>
<dt><strong><a name="item_auth">auth ( USERNAME, PASSWORD )</a></strong>
<dd>
<p>Attempt SASL authentication.</p>
</dd>
</li>
<dt><strong><a name="item_mail">mail ( ADDRESS [, OPTIONS] )</a></strong>
<dt><strong><a name="item_send">send ( ADDRESS )</a></strong>
<dt><strong><a name="item_send_or_mail">send_or_mail ( ADDRESS )</a></strong>
<dt><strong><a name="item_send_and_mail">send_and_mail ( ADDRESS )</a></strong>
<dd>
<p>Send the appropriate command to the server MAIL, SEND, SOML or SAML. <code>ADDRESS</code>
is the address of the sender. This initiates the sending of a message. The
method <a href="#item_recipient"><code>recipient</code></a> should be called for each address that the message is to
be sent to.</p>
</dd>
<dd>
<p>The <a href="#item_mail"><code>mail</code></a> method can some additional ESMTP OPTIONS which is passed
in hash like fashion, using key and value pairs. Possible options are:</p>
</dd>
<dd>
<pre>
Size => <bytes>
Return => "FULL" | "HDRS"
Bits => "7" | "8" | "binary"
Transaction => <ADDRESS>
Envelope => <ENVID>
XVERP => 1</pre>
</dd>
<dd>
<p>The <code>Return</code> and <code>Envelope</code> parameters are used for DSN (Delivery
Status Notification).</p>
</dd>
</li>
<dt><strong><a name="item_reset">reset ()</a></strong>
<dd>
<p>Reset the status of the server. This may be called after a message has been
initiated, but before any data has been sent, to cancel the sending of the
message.</p>
</dd>
</li>
<dt><strong><a name="item_recipient">recipient ( ADDRESS [, ADDRESS, [...]] [, OPTIONS ] )</a></strong>
<dd>
<p>Notify the server that the current message should be sent to all of the
addresses given. Each address is sent as a separate command to the server.
Should the sending of any address result in a failure then the process is
aborted and a <em>false</em> value is returned. It is up to the user to call
<a href="#item_reset"><code>reset</code></a> if they so desire.</p>
</dd>
<dd>
<p>The <a href="#item_recipient"><code>recipient</code></a> method can also pass additional case-sensitive OPTIONS as an
anonymous hash using key and value pairs. Possible options are:</p>
</dd>
<dd>
<pre>
Notify => ['NEVER'] or ['SUCCESS','FAILURE','DELAY'] (see below)
SkipBad => 1 (to ignore bad addresses)</pre>
</dd>
<dd>
<p>If <code>SkipBad</code> is true the <a href="#item_recipient"><code>recipient</code></a> will not return an error when a bad
address is encountered and it will return an array of addresses that did
succeed.</p>
</dd>
<dd>
<pre>
<span class="variable">$smtp</span><span class="operator">-></span><span class="variable">recipient</span><span class="operator">(</span><span class="variable">$recipient1</span><span class="operator">,</span><span class="variable">$recipient2</span><span class="operator">);</span> <span class="comment"># Good</span>
<span class="variable">$smtp</span><span class="operator">-></span><span class="variable">recipient</span><span class="operator">(</span><span class="variable">$recipient1</span><span class="operator">,</span><span class="variable">$recipient2</span><span class="operator">,</span> <span class="operator">{</span> <span class="string">SkipBad</span> <span class="operator">=></span> <span class="number">1</span> <span class="operator">}</span><span class="operator">);</span> <span class="comment"># Good</span>
<span class="variable">$smtp</span><span class="operator">-></span><span class="variable">recipient</span><span class="operator">(</span><span class="variable">$recipient1</span><span class="operator">,</span><span class="variable">$recipient2</span><span class="operator">,</span> <span class="operator">{</span> <span class="string">Notify</span> <span class="operator">=></span> <span class="operator">[</span><span class="string">'FAILURE'</span><span class="operator">,</span><span class="string">'DELAY'</span><span class="operator">]</span><span class="operator">,</span> <span class="string">SkipBad</span> <span class="operator">=></span> <span class="number">1</span> <span class="operator">}</span><span class="operator">);</span> <span class="comment"># Good</span>
<span class="variable">@goodrecips</span><span class="operator">=</span><span class="variable">$smtp</span><span class="operator">-></span><span class="variable">recipient</span><span class="operator">(</span><span class="variable">@recipients</span><span class="operator">,</span> <span class="operator">{</span> <span class="string">Notify</span> <span class="operator">=></span> <span class="operator">[</span><span class="string">'FAILURE'</span><span class="operator">]</span><span class="operator">,</span> <span class="string">SkipBad</span> <span class="operator">=></span> <span class="number">1</span> <span class="operator">}</span><span class="operator">);</span> <span class="comment"># Good</span>
<span class="variable">$smtp</span><span class="operator">-></span><span class="variable">recipient</span><span class="operator">(</span><span class="string">"$recipient,$recipient2"</span><span class="operator">);</span> <span class="comment"># BAD</span>
</pre>
</dd>
<dd>
<p>Notify is used to request Delivery Status Notifications (DSNs), but your
SMTP/ESMTP service may not respect this request depending upon its version and
your site's SMTP configuration.</p>
</dd>
<dd>
<p>Leaving out the Notify option usually defaults an SMTP service to its default
behavior equivalent to ['FAILURE'] notifications only, but again this may be
dependent upon your site's SMTP configuration.</p>
</dd>
<dd>
<p>The NEVER keyword must appear by itself if used within the Notify option and "requests
that a DSN not be returned to the sender under any conditions."</p>
</dd>
<dd>
<pre>
<span class="operator">{</span><span class="string">Notify</span> <span class="operator">=></span> <span class="operator">[</span><span class="string">'NEVER'</span><span class="operator">]</span><span class="operator">}</span>
</pre>
</dd>
<dd>
<pre>
<span class="variable">$smtp</span><span class="operator">-></span><span class="variable">recipient</span><span class="operator">(</span><span class="variable">@recipients</span><span class="operator">,</span> <span class="operator">{</span> <span class="string">Notify</span> <span class="operator">=></span> <span class="operator">[</span><span class="string">'NEVER'</span><span class="operator">]</span><span class="operator">,</span> <span class="string">SkipBad</span> <span class="operator">=></span> <span class="number">1</span> <span class="operator">}</span><span class="operator">);</span> <span class="comment"># Good</span>
</pre>
</dd>
<dd>
<p>You may use any combination of these three values 'SUCCESS','FAILURE','DELAY' in
the anonymous array reference as defined by RFC3461 (see <a href="http://rfc.net/rfc3461.html">http://rfc.net/rfc3461.html</a>
for more information. Note: quotations in this topic from same.).</p>
</dd>
<dd>
<p>A Notify parameter of 'SUCCESS' or 'FAILURE' "requests that a DSN be issued on
successful delivery or delivery failure, respectively."</p>
</dd>
<dd>
<p>A Notify parameter of 'DELAY' "indicates the sender's willingness to receive
delayed DSNs. Delayed DSNs may be issued if delivery of a message has been
delayed for an unusual amount of time (as determined by the Message Transfer
Agent (MTA) at which the message is delayed), but the final delivery status
(whether successful or failure) cannot be determined. The absence of the DELAY
keyword in a NOTIFY parameter requests that a "delayed" DSN NOT be issued under
any conditions."</p>
</dd>
<dd>
<pre>
<span class="operator">{</span><span class="string">Notify</span> <span class="operator">=></span> <span class="operator">[</span><span class="string">'SUCCESS'</span><span class="operator">,</span><span class="string">'FAILURE'</span><span class="operator">,</span><span class="string">'DELAY'</span><span class="operator">]</span><span class="operator">}</span>
</pre>
</dd>
<dd>
<pre>
<span class="variable">$smtp</span><span class="operator">-></span><span class="variable">recipient</span><span class="operator">(</span><span class="variable">@recipients</span><span class="operator">,</span> <span class="operator">{</span> <span class="string">Notify</span> <span class="operator">=></span> <span class="operator">[</span><span class="string">'FAILURE'</span><span class="operator">,</span><span class="string">'DELAY'</span><span class="operator">]</span><span class="operator">,</span> <span class="string">SkipBad</span> <span class="operator">=></span> <span class="number">1</span> <span class="operator">}</span><span class="operator">);</span> <span class="comment"># Good</span>
</pre>
</dd>
</li>
<dt><strong><a name="item_to">to ( ADDRESS [, ADDRESS [...]] )</a></strong>
<dt><strong><a name="item_cc">cc ( ADDRESS [, ADDRESS [...]] )</a></strong>
<dt><strong><a name="item_bcc">bcc ( ADDRESS [, ADDRESS [...]] )</a></strong>
<dd>
<p>Synonyms for <a href="#item_recipient"><code>recipient</code></a>.</p>
</dd>
</li>
<dt><strong><a name="item_data">data ( [ DATA ] )</a></strong>
<dd>
<p>Initiate the sending of the data from the current message.</p>
</dd>
<dd>
<p><code>DATA</code> may be a reference to a list or a list. If specified the contents
of <code>DATA</code> and a termination string <code>".\r\n"</code> is sent to the server. And the
result will be true if the data was accepted.</p>
</dd>
<dd>
<p>If <code>DATA</code> is not specified then the result will indicate that the server
wishes the data to be sent. The data must then be sent using the <code>datasend</code>
and <code>dataend</code> methods described in <a href="../../lib/Net/Cmd.html">the Net::Cmd manpage</a>.</p>
</dd>
</li>
<dt><strong><a name="item_expand">expand ( ADDRESS )</a></strong>
<dd>
<p>Request the server to expand the given address Returns an array
which contains the text read from the server.</p>
</dd>
</li>
<dt><strong><a name="item_verify">verify ( ADDRESS )</a></strong>
<dd>
<p>Verify that <code>ADDRESS</code> is a legitimate mailing address.</p>
</dd>
<dd>
<p>Most sites usually disable this feature in their SMTP service configuration.
Use "Debug => 1" option under <a href="#item_new"><code>new()</code></a> to see if disabled.</p>
</dd>
</li>
<dt><strong><a name="item_help">help ( [ $subject ] )</a></strong>
<dd>
<p>Request help text from the server. Returns the text or undef upon failure</p>
</dd>
</li>
<dt><strong><a name="item_quit">quit ()</a></strong>
<dd>
<p>Send the QUIT command to the remote SMTP server and close the socket connection.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="addresses">ADDRESSES</a></h1>
<p>Net::SMTP attempts to DWIM with addresses that are passed. For
example an application might extract The From: line from an email
and pass that to mail(). While this may work, it is not reccomended.
The application should really use a module like <a href="../../Mail/Address.html">the Mail::Address manpage</a>
to extract the mail address and pass that.</p>
<p>If <code>ExactAddresses</code> is passed to the contructor, then addresses
should be a valid rfc2821-quoted address, although Net::SMTP will
accept accept the address surrounded by angle brackets.</p>
<pre>
funny user@domain WRONG
"funny user"@domain RIGHT, recommended
<"funny user"@domain> OK</pre>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><a href="../../lib/Net/Cmd.html">the Net::Cmd manpage</a></p>
<p>
</p>
<hr />
<h1><a name="author">AUTHOR</a></h1>
<p>Graham Barr <<a href="mailto:gbarr@pobox.com">gbarr@pobox.com</a>></p>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<p>Copyright (c) 1995-2004 Graham Barr. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.</p>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?