about summary refs log tree commit
diff options
context:
space:
mode:
authorGraham Barr <gbarr@pobox.com>2013-02-19 14:12:36 -0800
committerGraham Barr <gbarr@pobox.com>2013-02-19 14:12:36 -0800
commitc241f063e5795f05d95e4885a89f2c7891b7eda9 (patch)
treec0ed32ffa640ecee5115453f151bb0b83946996a
parent80c5cbf48e2ceec181aa2116401ec96873a18d0f (diff)
parent076ad43fef75e02bf0322afb64cb3794c301bb9e (diff)
downloadperl-libnet-c241f063e5795f05d95e4885a89f2c7891b7eda9.tar.gz
Merge pull request #4 from chorny/master
better documentation for Net::SMTP (written from my own experience starting using it)
-rw-r--r--Net/SMTP.pm31
1 files changed, 20 insertions, 11 deletions
diff --git a/Net/SMTP.pm b/Net/SMTP.pm
index f69d3d1..9abb115 100644
--- a/Net/SMTP.pm
+++ b/Net/SMTP.pm
@@ -579,16 +579,18 @@ known as mailhost:
 
     use Net::SMTP;
 
-    $smtp = Net::SMTP->new('mailhost');
+    my $smtp = Net::SMTP->new('mailhost');
 
     $smtp->mail($ENV{USER});
-    $smtp->to('postmaster');
-
-    $smtp->data();
-    $smtp->datasend("To: postmaster\n");
-    $smtp->datasend("\n");
-    $smtp->datasend("A simple test message\n");
-    $smtp->dataend();
+    if ($smtp->to('postmaster')) {
+     $smtp->data();
+     $smtp->datasend("To: postmaster\n");
+     $smtp->datasend("\n");
+     $smtp->datasend("A simple test message\n");
+     $smtp->dataend();
+    } else {
+     print "Error: ", $smtp->message();
+    }
 
     $smtp->quit;
 
@@ -615,11 +617,14 @@ B<Hello> - SMTP requires that you identify yourself. This option
 specifies a string to pass as your mail domain. If not given localhost.localdomain
 will be used.
 
-B<Host> - SMTP host to connect to. It may be a single scalar, as defined for
-the C<PeerAddr> option in L<IO::Socket::INET>, or a reference to
+B<Host> - SMTP host to connect to. It may be a single scalar (hostname[:port]),
+as defined for the C<PeerAddr> option in L<IO::Socket::INET>, or a reference to
 an array with hosts to try in turn. The L</host> method will return the value
 which was used to connect to the host.
 
+B<Port> - port to connect to. Format - C<PeerHost> from L<IO::Socket::INET> new method.
+Default - 25.
+
 B<LocalAddr> and B<LocalPort> - These parameters are passed directly
 to IO::Socket to allow binding the socket to a local port.
 
@@ -695,7 +700,7 @@ Request a queue run for the DOMAIN given.
 
 =item auth ( USERNAME, PASSWORD )
 
-Attempt SASL authentication.
+Attempt SASL authentication. Requires Authen::SASL module.
 
 =item mail ( ADDRESS [, OPTIONS] )
 
@@ -831,6 +836,10 @@ Verify that C<ADDRESS> is a legitimate mailing address.
 Most sites usually disable this feature in their SMTP service configuration.
 Use "Debug => 1" option under new() to see if disabled.
 
+=item message ()
+
+Returns the text message returned from the last command. (Net::Cmd method)
+
 =item help ( [ $subject ] )
 
 Request help text from the server. Returns the text or undef upon failure