3 # Versions up to 2.31_1 Copyright (c) 1995-2004 Graham Barr <gbarr@pobox.com>.
5 # Changes in Version 2.31_2 onwards Copyright (C) 2013-2015 Steve Hay. All
7 # This module is free software; you can redistribute it and/or modify it under
8 # the same terms as Perl itself, i.e. under the terms of either the GNU General
9 # Public License or the Artistic License, as specified in the F<LICENCE> file.
24 our $VERSION = "3.07";
26 # Code for detecting if we can use SSL
27 my $ssl_class = eval {
28 require IO::Socket::SSL;
29 # first version with default CA on most platforms
30 no warnings 'numeric';
31 IO::Socket::SSL->VERSION(2.007);
32 } && 'IO::Socket::SSL';
34 my $nossl_warn = !$ssl_class &&
35 'To use SSL please install IO::Socket::SSL with version>=2.007';
37 # Code for detecting if we can use IPv6
38 my $family_key = 'Domain';
39 my $inet6_class = eval {
40 require IO::Socket::IP;
41 no warnings 'numeric';
42 IO::Socket::IP->VERSION(0.20) || die;
43 $family_key = 'Family';
44 } && 'IO::Socket::IP' || eval {
45 require IO::Socket::INET6;
46 no warnings 'numeric';
47 IO::Socket::INET6->VERSION(2.62);
48 } && 'IO::Socket::INET6';
50 sub can_ssl { $ssl_class };
51 sub can_inet6 { $inet6_class };
53 our @ISA = ('Net::Cmd', $inet6_class || 'IO::Socket::INET');
57 my $type = ref($self) || $self;
65 $host = delete $arg{Host};
70 die $nossl_warn if !$ssl_class;
74 my $hosts = defined $host ? $host : $NetConfig{smtp_hosts};
77 $arg{Timeout} = 120 if ! defined $arg{Timeout};
79 foreach my $h (@{ref($hosts) ? $hosts : [$hosts]}) {
80 $obj = $type->SUPER::new(
81 PeerAddr => ($host = $h),
82 PeerPort => $arg{Port} || 'smtp(25)',
83 LocalAddr => $arg{LocalAddr},
84 LocalPort => $arg{LocalPort},
85 $family_key => $arg{Domain} || $arg{Family},
87 Timeout => $arg{Timeout}
95 ${*$obj}{'net_smtp_arg'} = \%arg;
96 ${*$obj}{'net_smtp_host'} = $host;
99 Net::SMTP::_SSL->start_SSL($obj,%arg)
105 $obj->debug(exists $arg{Debug} ? $arg{Debug} : undef);
107 unless ($obj->response() == CMD_OK) {
108 my $err = ref($obj) . ": " . $obj->code . " " . $obj->message;
114 ${*$obj}{'net_smtp_exact_addr'} = $arg{ExactAddresses};
116 (${*$obj}{'net_smtp_banner'}) = $obj->message;
117 (${*$obj}{'net_smtp_domain'}) = $obj->message =~ /\A\s*(\S+)/;
119 if (!exists $arg{SendHello} || $arg{SendHello}) {
120 unless ($obj->hello($arg{Hello} || "")) {
121 my $err = ref($obj) . ": " . $obj->code . " " . $obj->message;
134 ${*$me}{'net_smtp_host'};
138 ## User interface methods
145 return ${*$me}{'net_smtp_banner'} || undef;
152 return ${*$me}{'net_smtp_domain'} || undef;
158 defined($self->supports('ETRN', 500, ["Command unknown: 'ETRN'"]))
164 my ($self, $username, $password) = @_;
167 require MIME::Base64;
168 require Authen::SASL;
169 } or $self->set_status(500, ["Need MIME::Base64 and Authen::SASL todo auth"]), return 0;
171 my $mechanisms = $self->supports('AUTH', 500, ["Command unknown: 'AUTH'"]);
172 return unless defined $mechanisms;
176 if (ref($username) and UNIVERSAL::isa($username, 'Authen::SASL')) {
178 my $requested_mechanisms = $sasl->mechanism();
179 if (! defined($requested_mechanisms) || $requested_mechanisms eq '') {
180 $sasl->mechanism($mechanisms);
184 die "auth(username, password)" if not length $username;
185 $sasl = Authen::SASL->new(
186 mechanism => $mechanisms,
190 authname => $username,
192 debug => $self->debug
200 # $client mechanism failed, so we need to exclude this mechanism from list
201 my $failed_mechanism = $client->mechanism;
202 return unless defined $failed_mechanism;
203 $self->debug_text("Auth mechanism failed: $failed_mechanism")
205 $mechanisms =~ s/\b\Q$failed_mechanism\E\b//;
206 return unless $mechanisms =~ /\S/;
207 $sasl->mechanism($mechanisms);
210 # We should probably allow the user to pass the host, but I don't
211 # currently know and SASL mechanisms that are used by smtp that need it
213 $client = $sasl->client_new('smtp', ${*$self}{'net_smtp_host'}, 0);
214 $str = $client->client_start;
215 } while (!defined $str);
217 # We don't support sasl mechanisms that encrypt the socket traffic.
218 # todo that we would really need to change the ISA hierarchy
219 # so we don't inherit from IO::Socket, but instead hold it in an attribute
221 my @cmd = ("AUTH", $client->mechanism);
224 push @cmd, MIME::Base64::encode_base64($str, '')
225 if defined $str and length $str;
227 while (($code = $self->command(@cmd)->response()) == CMD_MORE) {
229 MIME::Base64::encode_base64(
230 $client->client_step(MIME::Base64::decode_base64(($self->message)[0])), ''
241 my $domain = shift || "localhost.localdomain";
242 my $ok = $me->_EHLO($domain);
243 my @msg = $me->message;
246 my $h = ${*$me}{'net_smtp_esmtp'} = {};
247 foreach my $ln (@msg) {
249 if $ln =~ /([-\w]+)\b[= \t]*([^\n]*)/;
252 elsif ($me->status == CMD_ERROR) {
254 if $ok = $me->_HELO($domain);
258 ${*$me}{net_smtp_hello_domain} = $domain;
260 $msg[0] =~ /\A\s*(\S+)/;
266 $ssl_class or die $nossl_warn;
267 $self->_STARTTLS or return;
268 Net::SMTP::_SSL->start_SSL($self,
269 %{ ${*$self}{'net_smtp_arg'} }, # (ssl) args given in new
273 # another hello after starttls to read new ESMTP capabilities
274 return $self->hello(${*$self}{net_smtp_hello_domain});
281 return ${*$self}{'net_smtp_esmtp'}->{$cmd}
282 if exists ${*$self}{'net_smtp_esmtp'}->{$cmd};
283 $self->set_status(@_)
292 $addr = "" unless defined $addr;
294 if (${*$self}{'net_smtp_exact_addr'}) {
295 return $1 if $addr =~ /^\s*(<.*>)\s*$/s;
298 return $1 if $addr =~ /(<[^>]*>)/;
299 $addr =~ s/^\s+|\s+$//sg;
308 my $addr = _addr($me, shift);
315 if (exists ${*$me}{'net_smtp_esmtp'}) {
316 my $esmtp = ${*$me}{'net_smtp_esmtp'};
318 if (defined($v = delete $opt{Size})) {
319 if (exists $esmtp->{SIZE}) {
320 $opts .= sprintf " SIZE=%d", $v + 0;
323 carp 'Net::SMTP::mail: SIZE option not supported by host';
327 if (defined($v = delete $opt{Return})) {
328 if (exists $esmtp->{DSN}) {
329 $opts .= " RET=" . ((uc($v) eq "FULL") ? "FULL" : "HDRS");
332 carp 'Net::SMTP::mail: DSN option not supported by host';
336 if (defined($v = delete $opt{Bits})) {
338 if (exists $esmtp->{'8BITMIME'}) {
339 $opts .= " BODY=8BITMIME";
342 carp 'Net::SMTP::mail: 8BITMIME option not supported by host';
345 elsif ($v eq "binary") {
346 if (exists $esmtp->{'BINARYMIME'} && exists $esmtp->{'CHUNKING'}) {
347 $opts .= " BODY=BINARYMIME";
348 ${*$me}{'net_smtp_chunking'} = 1;
351 carp 'Net::SMTP::mail: BINARYMIME option not supported by host';
354 elsif (exists $esmtp->{'8BITMIME'} or exists $esmtp->{'BINARYMIME'}) {
355 $opts .= " BODY=7BIT";
358 carp 'Net::SMTP::mail: 8BITMIME and BINARYMIME options not supported by host';
362 if (defined($v = delete $opt{Transaction})) {
363 if (exists $esmtp->{CHECKPOINT}) {
364 $opts .= " TRANSID=" . _addr($me, $v);
367 carp 'Net::SMTP::mail: CHECKPOINT option not supported by host';
371 if (defined($v = delete $opt{Envelope})) {
372 if (exists $esmtp->{DSN}) {
373 $v =~ s/([^\041-\176]|=|\+)/sprintf "+%02X", ord($1)/sge;
374 $opts .= " ENVID=$v";
377 carp 'Net::SMTP::mail: DSN option not supported by host';
381 if (defined($v = delete $opt{ENVID})) {
383 # expected to be in a format as required by RFC 3461, xtext-encoded
384 if (exists $esmtp->{DSN}) {
385 $opts .= " ENVID=$v";
388 carp 'Net::SMTP::mail: DSN option not supported by host';
392 if (defined($v = delete $opt{AUTH})) {
394 # expected to be in a format as required by RFC 2554,
395 # rfc2821-quoted and xtext-encoded, or <>
396 if (exists $esmtp->{AUTH}) {
397 $v = '<>' if !defined($v) || $v eq '';
401 carp 'Net::SMTP::mail: AUTH option not supported by host';
405 if (defined($v = delete $opt{XVERP})) {
406 if (exists $esmtp->{'XVERP'}) {
410 carp 'Net::SMTP::mail: XVERP option not supported by host';
414 carp 'Net::SMTP::recipient: unknown option(s) ' . join(" ", keys %opt) . ' - ignored'
418 carp 'Net::SMTP::mail: ESMTP not supported by host - options discarded :-(';
422 $me->_MAIL("FROM:" . $addr . $opts);
426 sub send { my $me = shift; $me->_SEND("FROM:" . _addr($me, $_[0])) }
427 sub send_or_mail { my $me = shift; $me->_SOML("FROM:" . _addr($me, $_[0])) }
428 sub send_and_mail { my $me = shift; $me->_SAML("FROM:" . _addr($me, $_[0])) }
435 if (exists ${*$me}{'net_smtp_lastch'});
446 if (@_ && ref($_[-1])) {
447 my %opt = %{pop(@_)};
450 $skip_bad = delete $opt{'SkipBad'};
452 if (exists ${*$smtp}{'net_smtp_esmtp'}) {
453 my $esmtp = ${*$smtp}{'net_smtp_esmtp'};
455 if (defined($v = delete $opt{Notify})) {
456 if (exists $esmtp->{DSN}) {
457 $opts .= " NOTIFY=" . join(",", map { uc $_ } @$v);
460 carp 'Net::SMTP::recipient: DSN option not supported by host';
464 if (defined($v = delete $opt{ORcpt})) {
465 if (exists $esmtp->{DSN}) {
466 $opts .= " ORCPT=" . $v;
469 carp 'Net::SMTP::recipient: DSN option not supported by host';
473 carp 'Net::SMTP::recipient: unknown option(s) ' . join(" ", keys %opt) . ' - ignored'
477 carp 'Net::SMTP::recipient: ESMTP not supported by host - options discarded :-(';
482 foreach my $addr (@_) {
483 if ($smtp->_RCPT("TO:" . _addr($smtp, $addr) . $opts)) {
484 push(@ok, $addr) if $skip_bad;
491 return $skip_bad ? @ok : 1;
504 if (exists ${*$me}{'net_smtp_chunking'}) {
505 carp 'Net::SMTP::data: CHUNKING extension in use, must call bdat instead';
508 my $ok = $me->_DATA() && $me->datasend(@_);
520 if (exists ${*$me}{'net_smtp_chunking'}) {
523 $me->_BDAT(length $data)
524 && $me->rawdatasend($data)
525 && $me->response() == CMD_OK;
528 carp 'Net::SMTP::bdat: CHUNKING extension is not in use, call data instead';
536 if (exists ${*$me}{'net_smtp_chunking'}) {
539 $me->_BDAT(length $data, "LAST")
540 && $me->rawdatasend($data)
541 && $me->response() == CMD_OK;
544 carp 'Net::SMTP::bdat: CHUNKING extension is not in use, call data instead';
551 return unless $me->_DATA();
565 sub verify { shift->_VRFY(@_) }
572 ? scalar $me->message
595 sub _EHLO { shift->command("EHLO", @_)->response() == CMD_OK }
596 sub _HELO { shift->command("HELO", @_)->response() == CMD_OK }
597 sub _MAIL { shift->command("MAIL", @_)->response() == CMD_OK }
598 sub _RCPT { shift->command("RCPT", @_)->response() == CMD_OK }
599 sub _SEND { shift->command("SEND", @_)->response() == CMD_OK }
600 sub _SAML { shift->command("SAML", @_)->response() == CMD_OK }
601 sub _SOML { shift->command("SOML", @_)->response() == CMD_OK }
602 sub _VRFY { shift->command("VRFY", @_)->response() == CMD_OK }
603 sub _EXPN { shift->command("EXPN", @_)->response() == CMD_OK }
604 sub _HELP { shift->command("HELP", @_)->response() == CMD_OK }
605 sub _RSET { shift->command("RSET")->response() == CMD_OK }
606 sub _NOOP { shift->command("NOOP")->response() == CMD_OK }
607 sub _QUIT { shift->command("QUIT")->response() == CMD_OK }
608 sub _DATA { shift->command("DATA")->response() == CMD_MORE }
609 sub _BDAT { shift->command("BDAT", @_) }
610 sub _TURN { shift->unsupported(@_); }
611 sub _ETRN { shift->command("ETRN", @_)->response() == CMD_OK }
612 sub _AUTH { shift->command("AUTH", @_)->response() == CMD_OK }
613 sub _STARTTLS { shift->command("STARTTLS")->response() == CMD_OK }
617 package Net::SMTP::_SSL;
618 our @ISA = ( $ssl_class ? ($ssl_class):(), 'Net::SMTP' );
619 sub starttls { die "SMTP connection is already in SSL mode" }
621 my ($class,$smtp,%arg) = @_;
622 delete @arg{ grep { !m{^SSL_} } keys %arg };
623 ( $arg{SSL_verifycn_name} ||= $smtp->host )
624 =~s{(?<!:):[\w()]+$}{}; # strip port
625 $arg{SSL_hostname} = $arg{SSL_verifycn_name}
626 if ! defined $arg{SSL_hostname} && $class->can_client_sni;
627 $arg{SSL_verifycn_scheme} ||= 'smtp';
628 my $ok = $class->SUPER::start_SSL($smtp,%arg);
629 $@ = $ssl_class->errstr if !$ok;
642 Net::SMTP - Simple Mail Transfer Protocol Client
649 $smtp = Net::SMTP->new('mailhost');
650 $smtp = Net::SMTP->new('mailhost', Timeout => 60);
654 This module implements a client interface to the SMTP and ESMTP
655 protocol, enabling a perl5 application to talk to SMTP servers. This
656 documentation assumes that you are familiar with the concepts of the
657 SMTP protocol described in RFC2821.
658 With L<IO::Socket::SSL> installed it also provides support for implicit and
659 explicit TLS encryption, i.e. SMTPS or SMTP+STARTTLS.
661 The Net::SMTP class is a subclass of Net::Cmd and (depending on avaibility) of
662 IO::Socket::IP, IO::Socket::INET6 or IO::Socket::INET.
666 This example prints the mail domain name of the SMTP server known as mailhost:
668 #!/usr/local/bin/perl -w
672 $smtp = Net::SMTP->new('mailhost');
673 print $smtp->domain,"\n";
676 This example sends a small message to the postmaster at the SMTP server
679 #!/usr/local/bin/perl -w
683 my $smtp = Net::SMTP->new('mailhost');
685 $smtp->mail($ENV{USER});
686 if ($smtp->to('postmaster')) {
688 $smtp->datasend("To: postmaster\n");
689 $smtp->datasend("\n");
690 $smtp->datasend("A simple test message\n");
693 print "Error: ", $smtp->message();
702 =item new ( [ HOST ] [, OPTIONS ] )
704 This is the constructor for a new Net::SMTP object. C<HOST> is the
705 name of the remote host to which an SMTP connection is required.
707 On failure C<undef> will be returned and C<$@> will contain the reason
710 C<HOST> is optional. If C<HOST> is not given then it may instead be
711 passed as the C<Host> option described below. If neither is given then
712 the C<SMTP_Hosts> specified in C<Net::Config> will be used.
714 C<OPTIONS> are passed in a hash like fashion, using key and value pairs.
715 Possible options are:
717 B<Hello> - SMTP requires that you identify yourself. This option
718 specifies a string to pass as your mail domain. If not given localhost.localdomain
721 B<SendHello> - If false then the EHLO (or HELO) command that is normally sent
722 when constructing the object will not be sent. In that case the command will
723 have to be sent manually by calling C<hello()> instead.
725 B<Host> - SMTP host to connect to. It may be a single scalar (hostname[:port]),
726 as defined for the C<PeerAddr> option in L<IO::Socket::INET>, or a reference to
727 an array with hosts to try in turn. The L</host> method will return the value
728 which was used to connect to the host.
729 Format - C<PeerHost> from L<IO::Socket::INET> new method.
731 B<Port> - port to connect to.
732 Default - 25 for plain SMTP and 465 for immediate SSL.
734 B<SSL> - If the connection should be done from start with SSL, contrary to later
735 upgrade with C<starttls>.
736 You can use SSL arguments as documented in L<IO::Socket::SSL>, but it will
737 usually use the right arguments already.
739 B<LocalAddr> and B<LocalPort> - These parameters are passed directly
740 to IO::Socket to allow binding the socket to a specific local address and port.
742 B<Domain> - This parameter is passed directly to IO::Socket and makes it
743 possible to enforce IPv4 connections even if L<IO::Socket::IP> is used as super
744 class. Alternatively B<Family> can be used.
746 B<Timeout> - Maximum time, in seconds, to wait for a response from the
747 SMTP server (default: 120)
749 B<ExactAddresses> - If true the all ADDRESS arguments must be as
750 defined by C<addr-spec> in RFC2822. If not given, or false, then
751 Net::SMTP will attempt to extract the address from the value passed.
753 B<Debug> - Enable debugging information
759 $smtp = Net::SMTP->new('mailhost',
760 Hello => 'my.mail.domain',
766 $smtp = Net::SMTP->new(
768 Hello => 'my.mail.domain',
773 # the same with direct SSL
774 $smtp = Net::SMTP->new('mailhost',
775 Hello => 'my.mail.domain',
781 # Connect to the default server from Net::config
782 $smtp = Net::SMTP->new(
783 Hello => 'my.mail.domain',
791 Unless otherwise stated all methods return either a I<true> or I<false>
792 value, with I<true> meaning that the operation was a success. When a method
793 states that it returns a value, failure will be returned as I<undef> or an
796 C<Net::SMTP> inherits from C<Net::Cmd> so methods defined in C<Net::Cmd> may
797 be used to send commands to the remote SMTP server in addition to the methods
804 Returns the banner message which the server replied with when the
805 initial connection was made.
809 Returns the domain that the remote SMTP server identified itself as during
812 =item hello ( DOMAIN )
814 Tell the remote server the mail domain which you are in using the EHLO
815 command (or HELO if EHLO fails). Since this method is invoked
816 automatically when the Net::SMTP object is constructed the user should
817 normally not have to call it manually.
821 Returns the value used by the constructor, and passed to IO::Socket::INET,
822 to connect to the host.
824 =item etrn ( DOMAIN )
826 Request a queue run for the DOMAIN given.
828 =item starttls ( SSLARGS )
830 Upgrade existing plain connection to SSL.
831 You can use SSL arguments as documented in L<IO::Socket::SSL>, but it will
832 usually use the right arguments already.
834 =item auth ( USERNAME, PASSWORD )
836 Attempt SASL authentication. Requires Authen::SASL module.
838 =item mail ( ADDRESS [, OPTIONS] )
840 =item send ( ADDRESS )
842 =item send_or_mail ( ADDRESS )
844 =item send_and_mail ( ADDRESS )
846 Send the appropriate command to the server MAIL, SEND, SOML or SAML. C<ADDRESS>
847 is the address of the sender. This initiates the sending of a message. The
848 method C<recipient> should be called for each address that the message is to
851 The C<mail> method can some additional ESMTP OPTIONS which is passed
852 in hash like fashion, using key and value pairs. Possible options are:
855 Return => "FULL" | "HDRS"
856 Bits => "7" | "8" | "binary"
857 Transaction => <ADDRESS>
858 Envelope => <ENVID> # xtext-encodes its argument
859 ENVID => <ENVID> # similar to Envelope, but expects argument encoded
861 AUTH => <submitter> # encoded address according to RFC 2554
863 The C<Return> and C<Envelope> parameters are used for DSN (Delivery
864 Status Notification).
866 The submitter address in C<AUTH> option is expected to be in a format as
867 required by RFC 2554, in an RFC2821-quoted form and xtext-encoded, or <> .
871 Reset the status of the server. This may be called after a message has been
872 initiated, but before any data has been sent, to cancel the sending of the
875 =item recipient ( ADDRESS [, ADDRESS, [...]] [, OPTIONS ] )
877 Notify the server that the current message should be sent to all of the
878 addresses given. Each address is sent as a separate command to the server.
879 Should the sending of any address result in a failure then the process is
880 aborted and a I<false> value is returned. It is up to the user to call
881 C<reset> if they so desire.
883 The C<recipient> method can also pass additional case-sensitive OPTIONS as an
884 anonymous hash using key and value pairs. Possible options are:
886 Notify => ['NEVER'] or ['SUCCESS','FAILURE','DELAY'] (see below)
888 SkipBad => 1 (to ignore bad addresses)
890 If C<SkipBad> is true the C<recipient> will not return an error when a bad
891 address is encountered and it will return an array of addresses that did
894 $smtp->recipient($recipient1,$recipient2); # Good
895 $smtp->recipient($recipient1,$recipient2, { SkipBad => 1 }); # Good
896 $smtp->recipient($recipient1,$recipient2, { Notify => ['FAILURE','DELAY'], SkipBad => 1 }); # Good
897 @goodrecips=$smtp->recipient(@recipients, { Notify => ['FAILURE'], SkipBad => 1 }); # Good
898 $smtp->recipient("$recipient,$recipient2"); # BAD
900 Notify is used to request Delivery Status Notifications (DSNs), but your
901 SMTP/ESMTP service may not respect this request depending upon its version and
902 your site's SMTP configuration.
904 Leaving out the Notify option usually defaults an SMTP service to its default
905 behavior equivalent to ['FAILURE'] notifications only, but again this may be
906 dependent upon your site's SMTP configuration.
908 The NEVER keyword must appear by itself if used within the Notify option and "requests
909 that a DSN not be returned to the sender under any conditions."
911 {Notify => ['NEVER']}
913 $smtp->recipient(@recipients, { Notify => ['NEVER'], SkipBad => 1 }); # Good
915 You may use any combination of these three values 'SUCCESS','FAILURE','DELAY' in
916 the anonymous array reference as defined by RFC3461 (see http://www.ietf.org/rfc/rfc3461.txt
917 for more information. Note: quotations in this topic from same.).
919 A Notify parameter of 'SUCCESS' or 'FAILURE' "requests that a DSN be issued on
920 successful delivery or delivery failure, respectively."
922 A Notify parameter of 'DELAY' "indicates the sender's willingness to receive
923 delayed DSNs. Delayed DSNs may be issued if delivery of a message has been
924 delayed for an unusual amount of time (as determined by the Message Transfer
925 Agent (MTA) at which the message is delayed), but the final delivery status
926 (whether successful or failure) cannot be determined. The absence of the DELAY
927 keyword in a NOTIFY parameter requests that a "delayed" DSN NOT be issued under
930 {Notify => ['SUCCESS','FAILURE','DELAY']}
932 $smtp->recipient(@recipients, { Notify => ['FAILURE','DELAY'], SkipBad => 1 }); # Good
934 ORcpt is also part of the SMTP DSN extension according to RFC3461.
935 It is used to pass along the original recipient that the mail was first
936 sent to. The machine that generates a DSN will use this address to inform
937 the sender, because he can't know if recipients get rewritten by mail servers.
938 It is expected to be in a format as required by RFC3461, xtext-encoded.
940 =item to ( ADDRESS [, ADDRESS [...]] )
942 =item cc ( ADDRESS [, ADDRESS [...]] )
944 =item bcc ( ADDRESS [, ADDRESS [...]] )
946 Synonyms for C<recipient>.
948 =item data ( [ DATA ] )
950 Initiate the sending of the data from the current message.
952 C<DATA> may be a reference to a list or a list and must be encoded by the
953 caller to octets of whatever encoding is required, e.g. by using the Encode
954 module's C<encode()> function.
956 If specified the contents of C<DATA> and a termination string C<".\r\n"> is
957 sent to the server. The result will be true if the data was accepted.
959 If C<DATA> is not specified then the result will indicate that the server
960 wishes the data to be sent. The data must then be sent using the C<datasend>
961 and C<dataend> methods described in L<Net::Cmd>.
965 =item bdatlast ( DATA )
967 Use the alternate DATA command "BDAT" of the data chunking service extension
968 defined in RFC1830 for efficiently sending large MIME messages.
970 =item expand ( ADDRESS )
972 Request the server to expand the given address Returns an array
973 which contains the text read from the server.
975 =item verify ( ADDRESS )
977 Verify that C<ADDRESS> is a legitimate mailing address.
979 Most sites usually disable this feature in their SMTP service configuration.
980 Use "Debug => 1" option under new() to see if disabled.
982 =item help ( [ $subject ] )
984 Request help text from the server. Returns the text or undef upon failure
988 Send the QUIT command to the remote SMTP server and close the socket connection.
992 Returns whether we can use IPv6.
996 Returns whether we can use SSL.
1002 Net::SMTP attempts to DWIM with addresses that are passed. For
1003 example an application might extract The From: line from an email
1004 and pass that to mail(). While this may work, it is not recommended.
1005 The application should really use a module like L<Mail::Address>
1006 to extract the mail address and pass that.
1008 If C<ExactAddresses> is passed to the constructor, then addresses
1009 should be a valid rfc2821-quoted address, although Net::SMTP will
1010 accept the address surrounded by angle brackets.
1012 funny user@domain WRONG
1013 "funny user"@domain RIGHT, recommended
1014 <"funny user"@domain> OK
1023 Graham Barr E<lt>F<gbarr@pobox.com>E<gt>
1025 Steve Hay E<lt>F<shay@cpan.org>E<gt> is now maintaining libnet as of version
1030 Versions up to 2.31_1 Copyright (c) 1995-2004 Graham Barr. All rights reserved.
1031 Changes in Version 2.31_2 onwards Copyright (C) 2013-2015 Steve Hay. All rights
1034 This module is free software; you can redistribute it and/or modify it under the
1035 same terms as Perl itself, i.e. under the terms of either the GNU General Public
1036 License or the Artistic License, as specified in the F<LICENCE> file.