releasing/cbrtools/perl/Net/SMTP.pm
author lorewang
Wed, 01 Dec 2010 16:05:36 +0800
changeset 715 e0739b8406dd
parent 602 3145852acc89
permissions -rw-r--r--
Specify extenal tool with path
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     1
# Net::SMTP.pm
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     2
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     3
# Copyright (c) 1995-1997 Graham Barr <gbarr@pobox.com>. All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     4
# This program is free software; you can redistribute it and/or
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     5
# modify it under the same terms as Perl itself.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     6
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     7
package Net::SMTP;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     8
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     9
require 5.001;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    10
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    11
use strict;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    12
use vars qw($VERSION @ISA);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    13
use Socket 1.3;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    14
use Carp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    15
use IO::Socket;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    16
use Net::Cmd;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    17
use Net::Config;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    18
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
$VERSION = "2.26"; # $Id: //depot/libnet/Net/SMTP.pm#31 $
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
@ISA = qw(Net::Cmd IO::Socket::INET);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
sub new
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
 my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
 my $type = ref($self) || $self;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
 my $host = shift if @_ % 2;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
 my %arg  = @_; 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
 my $hosts = defined $host ? $host : $NetConfig{smtp_hosts};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
 my $obj;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
 my $h;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
 foreach $h (@{ref($hosts) ? $hosts : [ $hosts ]})
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
   $obj = $type->SUPER::new(PeerAddr => ($host = $h), 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
			    PeerPort => $arg{Port} || 'smtp(25)',
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
			    LocalAddr => $arg{LocalAddr},
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
			    LocalPort => $arg{LocalPort},
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
			    Proto    => 'tcp',
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
			    Timeout  => defined $arg{Timeout}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
						? $arg{Timeout}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
						: 120
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
			   ) and last;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
 return undef
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
	unless defined $obj;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
 $obj->autoflush(1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
 $obj->debug(exists $arg{Debug} ? $arg{Debug} : undef);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
 unless ($obj->response() == CMD_OK)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
   $obj->close();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
   return undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
 ${*$obj}{'net_smtp_exact_addr'} = $arg{ExactAddresses};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
 ${*$obj}{'net_smtp_host'} = $host;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
 (${*$obj}{'net_smtp_banner'}) = $obj->message;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
 (${*$obj}{'net_smtp_domain'}) = $obj->message =~ /\A\s*(\S+)/;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
 unless($obj->hello($arg{Hello} || ""))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
   $obj->close();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
   return undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
 $obj;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
##
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
## User interface methods
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
##
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
sub banner
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
 my $me = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
 return ${*$me}{'net_smtp_banner'} || undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
sub domain
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
 my $me = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
 return ${*$me}{'net_smtp_domain'} || undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
sub etrn {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
    my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
    defined($self->supports('ETRN',500,["Command unknown: 'ETRN'"])) &&
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
	$self->_ETRN(@_);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
sub auth {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
    my ($self, $username, $password) = @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
    require MIME::Base64;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
    require Authen::SASL;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
    my $mechanisms = $self->supports('AUTH',500,["Command unknown: 'AUTH'"]);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
    return unless defined $mechanisms;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
    my $sasl;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
    if (ref($username) and UNIVERSAL::isa($username,'Authen::SASL')) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
      $sasl = $username;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
      $sasl->mechanism($mechanisms);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
      die "auth(username, password)" if not length $username;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
      $sasl = Authen::SASL->new(mechanism=> $mechanisms,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
				callback => { user => $username,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
                                              pass => $password,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
					      authname => $username,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
                                            });
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
    # We should probably allow the user to pass the host, but I don't
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
    # currently know and SASL mechanisms that are used by smtp that need it
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
    my $client = $sasl->client_new('smtp',${*$self}{'net_smtp_host'},0);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
    my $str    = $client->client_start;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
    # We dont support sasl mechanisms that encrypt the socket traffic.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
    # todo that we would really need to change the ISA hierarchy
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
    # so we dont inherit from IO::Socket, but instead hold it in an attribute
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
    my @cmd = ("AUTH", $client->mechanism);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
    my $code;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
    push @cmd, MIME::Base64::encode_base64($str,'')
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
      if defined $str and length $str;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
    while (($code = $self->command(@cmd)->response()) == CMD_MORE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
      @cmd = (MIME::Base64::encode_base64(
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
	$client->client_step(
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
	  MIME::Base64::decode_base64(
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
	    ($self->message)[0]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
	  )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
	), ''
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
      ));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
    $code == CMD_OK;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
sub hello
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
 my $me = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
 my $domain = shift || "localhost.localdomain";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
 my $ok = $me->_EHLO($domain);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
 my @msg = $me->message;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
 if($ok)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   158
   my $h = ${*$me}{'net_smtp_esmtp'} = {};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   159
   my $ln;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   160
   foreach $ln (@msg) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
     $h->{uc $1} = $2
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
	if $ln =~ /(\w+)\b[= \t]*([^\n]*)/;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   164
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   165
 elsif($me->status == CMD_ERROR) 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   166
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   167
   @msg = $me->message
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   168
	if $ok = $me->_HELO($domain);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   169
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   170
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   171
 return undef unless $ok;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   172
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   173
 $msg[0] =~ /\A\s*(\S+)/;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   174
 return ($1 || " ");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   175
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   176
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   177
sub supports {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   178
    my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   179
    my $cmd = uc shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   180
    return ${*$self}{'net_smtp_esmtp'}->{$cmd}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   181
	if exists ${*$self}{'net_smtp_esmtp'}->{$cmd};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   182
    $self->set_status(@_)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   183
	if @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   184
    return;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   185
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   186
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   187
sub _addr {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   188
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   189
  my $addr = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   190
  $addr = "" unless defined $addr;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   191
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   192
  if (${*$self}{'net_smtp_exact_addr'}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   193
    return $1 if $addr =~ /^\s*(<.*>)\s*$/s;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   194
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   195
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   196
    return $1 if $addr =~ /(<[^>]*>)/;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   197
    $addr =~ s/^\s+|\s+$//sg;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   198
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   199
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   200
  "<$addr>";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   201
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   202
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   203
sub mail
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   204
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   205
 my $me = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   206
 my $addr = _addr($me, shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   207
 my $opts = "";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   208
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   209
 if(@_)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   210
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   211
   my %opt = @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   212
   my($k,$v);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   213
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   214
   if(exists ${*$me}{'net_smtp_esmtp'})
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   215
    {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   216
     my $esmtp = ${*$me}{'net_smtp_esmtp'};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   217
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   218
     if(defined($v = delete $opt{Size}))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   219
      {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   220
       if(exists $esmtp->{SIZE})
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   221
        {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   222
         $opts .= sprintf " SIZE=%d", $v + 0
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   223
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   224
       else
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   225
        {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   226
	 carp 'Net::SMTP::mail: SIZE option not supported by host';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   227
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   228
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   229
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   230
     if(defined($v = delete $opt{Return}))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   231
      {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   232
       if(exists $esmtp->{DSN})
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   233
        {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   234
	 $opts .= " RET=" . ((uc($v) eq "FULL") ? "FULL" : "HDRS");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   235
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   236
       else
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   237
        {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   238
	 carp 'Net::SMTP::mail: DSN option not supported by host';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   239
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   240
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   241
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   242
     if(defined($v = delete $opt{Bits}))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   243
      {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   244
       if($v eq "8")
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   245
        {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   246
         if(exists $esmtp->{'8BITMIME'})
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   247
          {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   248
	 $opts .= " BODY=8BITMIME";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   249
          }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   250
         else
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   251
          {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   252
	 carp 'Net::SMTP::mail: 8BITMIME option not supported by host';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   253
          }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   254
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   255
       elsif($v eq "binary")
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   256
        {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   257
         if(exists $esmtp->{'BINARYMIME'} && exists $esmtp->{'CHUNKING'})
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   258
          {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   259
   $opts .= " BODY=BINARYMIME";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   260
   ${*$me}{'net_smtp_chunking'} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   261
          }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   262
         else
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   263
          {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   264
   carp 'Net::SMTP::mail: BINARYMIME option not supported by host';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   265
          }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   266
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   267
       elsif(exists $esmtp->{'8BITMIME'} or exists $esmtp->{'BINARYMIME'})
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   268
        {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   269
   $opts .= " BODY=7BIT";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   270
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   271
       else
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   272
        {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   273
   carp 'Net::SMTP::mail: 8BITMIME and BINARYMIME options not supported by host';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   274
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   275
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   276
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   277
     if(defined($v = delete $opt{Transaction}))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   278
      {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   279
       if(exists $esmtp->{CHECKPOINT})
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   280
        {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   281
	 $opts .= " TRANSID=" . _addr($me, $v);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   282
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   283
       else
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   284
        {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   285
	 carp 'Net::SMTP::mail: CHECKPOINT option not supported by host';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   286
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   287
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   288
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   289
     if(defined($v = delete $opt{Envelope}))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   290
      {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   291
       if(exists $esmtp->{DSN})
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   292
        {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   293
	 $v =~ s/([^\041-\176]|=|\+)/sprintf "+%02x", ord($1)/sge;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   294
	 $opts .= " ENVID=$v"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   295
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   296
       else
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   297
        {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   298
	 carp 'Net::SMTP::mail: DSN option not supported by host';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   299
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   300
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   301
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   302
     carp 'Net::SMTP::recipient: unknown option(s) '
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   303
		. join(" ", keys %opt)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   304
		. ' - ignored'
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   305
	if scalar keys %opt;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   306
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   307
   else
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   308
    {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   309
     carp 'Net::SMTP::mail: ESMTP not supported by host - options discarded :-(';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   310
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   311
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   312
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   313
 $me->_MAIL("FROM:".$addr.$opts);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   314
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   315
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   316
sub send	  { my $me = shift; $me->_SEND("FROM:" . _addr($me, $_[0])) }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   317
sub send_or_mail  { my $me = shift; $me->_SOML("FROM:" . _addr($me, $_[0])) }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   318
sub send_and_mail { my $me = shift; $me->_SAML("FROM:" . _addr($me, $_[0])) }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   319
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   320
sub reset
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   321
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   322
 my $me = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   323
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   324
 $me->dataend()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   325
	if(exists ${*$me}{'net_smtp_lastch'});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   326
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   327
 $me->_RSET();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   328
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   329
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   330
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   331
sub recipient
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   332
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   333
 my $smtp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   334
 my $opts = "";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   335
 my $skip_bad = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   336
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   337
 if(@_ && ref($_[-1]))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   338
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   339
   my %opt = %{pop(@_)};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   340
   my $v;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   341
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   342
   $skip_bad = delete $opt{'SkipBad'};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   343
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   344
   if(exists ${*$smtp}{'net_smtp_esmtp'})
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   345
    {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   346
     my $esmtp = ${*$smtp}{'net_smtp_esmtp'};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   347
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   348
     if(defined($v = delete $opt{Notify}))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   349
      {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   350
       if(exists $esmtp->{DSN})
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   351
        {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   352
	 $opts .= " NOTIFY=" . join(",",map { uc $_ } @$v)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   353
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   354
       else
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   355
        {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   356
	 carp 'Net::SMTP::recipient: DSN option not supported by host';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   357
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   358
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   359
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   360
     carp 'Net::SMTP::recipient: unknown option(s) '
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   361
		. join(" ", keys %opt)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   362
		. ' - ignored'
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   363
	if scalar keys %opt;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   364
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   365
   elsif(%opt)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   366
    {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   367
     carp 'Net::SMTP::recipient: ESMTP not supported by host - options discarded :-(';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   368
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   369
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   370
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   371
 my @ok;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   372
 my $addr;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   373
 foreach $addr (@_) 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   374
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   375
    if($smtp->_RCPT("TO:" . _addr($smtp, $addr) . $opts)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   376
      push(@ok,$addr) if $skip_bad;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   377
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   378
    elsif(!$skip_bad) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   379
      return 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   380
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   381
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   382
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   383
 return $skip_bad ? @ok : 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   384
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   385
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   386
BEGIN {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   387
  *to  = \&recipient;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   388
  *cc  = \&recipient;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   389
  *bcc = \&recipient;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   390
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   391
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   392
sub data
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   393
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   394
 my $me = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   395
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   396
 if(exists ${*$me}{'net_smtp_chunking'})
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   397
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   398
   carp 'Net::SMTP::data: CHUNKING extension in use, must call bdat instead';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   399
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   400
 else
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   401
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   402
   my $ok = $me->_DATA() && $me->datasend(@_);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   403
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   404
   $ok && @_ ? $me->dataend
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   405
	     : $ok;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   406
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   407
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   408
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   409
sub bdat
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   410
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   411
 my $me = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   412
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   413
 if(exists ${*$me}{'net_smtp_chunking'})
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   414
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   415
   my $data = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   416
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   417
   $me->_BDAT(length $data) && $me->rawdatasend($data) &&
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   418
     $me->response() == CMD_OK;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   419
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   420
 else
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   421
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   422
   carp 'Net::SMTP::bdat: CHUNKING extension is not in use, call data instead';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   423
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   424
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   425
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   426
sub bdatlast
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   427
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   428
 my $me = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   429
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   430
 if(exists ${*$me}{'net_smtp_chunking'})
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   431
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   432
   my $data = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   433
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   434
   $me->_BDAT(length $data, "LAST") && $me->rawdatasend($data) &&
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   435
     $me->response() == CMD_OK;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   436
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   437
 else
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   438
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   439
   carp 'Net::SMTP::bdat: CHUNKING extension is not in use, call data instead';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   440
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   441
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   442
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   443
sub datafh {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   444
  my $me = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   445
  return unless $me->_DATA();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   446
  return $me->tied_fh;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   447
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   448
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   449
sub expand
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   450
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   451
 my $me = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   452
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   453
 $me->_EXPN(@_) ? ($me->message)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   454
		: ();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   455
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   456
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   457
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   458
sub verify { shift->_VRFY(@_) }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   459
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   460
sub help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   461
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   462
 my $me = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   463
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   464
 $me->_HELP(@_) ? scalar $me->message
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   465
	        : undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   466
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   467
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   468
sub quit
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   469
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   470
 my $me = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   471
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   472
 $me->_QUIT;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   473
 $me->close;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   474
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   475
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   476
sub DESTROY
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   477
{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   478
# ignore
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   479
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   480
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   481
##
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   482
## RFC821 commands
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   483
##
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   484
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   485
sub _EHLO { shift->command("EHLO", @_)->response()  == CMD_OK }   
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   486
sub _HELO { shift->command("HELO", @_)->response()  == CMD_OK }   
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   487
sub _MAIL { shift->command("MAIL", @_)->response()  == CMD_OK }   
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   488
sub _RCPT { shift->command("RCPT", @_)->response()  == CMD_OK }   
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   489
sub _SEND { shift->command("SEND", @_)->response()  == CMD_OK }   
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   490
sub _SAML { shift->command("SAML", @_)->response()  == CMD_OK }   
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   491
sub _SOML { shift->command("SOML", @_)->response()  == CMD_OK }   
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   492
sub _VRFY { shift->command("VRFY", @_)->response()  == CMD_OK }   
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   493
sub _EXPN { shift->command("EXPN", @_)->response()  == CMD_OK }   
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   494
sub _HELP { shift->command("HELP", @_)->response()  == CMD_OK }   
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   495
sub _RSET { shift->command("RSET")->response()	    == CMD_OK }   
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   496
sub _NOOP { shift->command("NOOP")->response()	    == CMD_OK }   
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   497
sub _QUIT { shift->command("QUIT")->response()	    == CMD_OK }   
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   498
sub _DATA { shift->command("DATA")->response()	    == CMD_MORE } 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   499
sub _BDAT { shift->command("BDAT", @_) }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   500
sub _TURN { shift->unsupported(@_); } 			   	  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   501
sub _ETRN { shift->command("ETRN", @_)->response()  == CMD_OK }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   502
sub _AUTH { shift->command("AUTH", @_)->response()  == CMD_OK }   
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   503
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   504
1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   505
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   506
__END__
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   507
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   508
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   509
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   510
Net::SMTP - Simple Mail Transfer Protocol Client
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   511
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   512
=head1 SYNOPSIS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   513
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   514
    use Net::SMTP;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   515
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   516
    # Constructors
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   517
    $smtp = Net::SMTP->new('mailhost');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   518
    $smtp = Net::SMTP->new('mailhost', Timeout => 60);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   519
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   520
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   521
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   522
This module implements a client interface to the SMTP and ESMTP
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   523
protocol, enabling a perl5 application to talk to SMTP servers. This
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   524
documentation assumes that you are familiar with the concepts of the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   525
SMTP protocol described in RFC821.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   526
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   527
A new Net::SMTP object must be created with the I<new> method. Once
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   528
this has been done, all SMTP commands are accessed through this object.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   529
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   530
The Net::SMTP class is a subclass of Net::Cmd and IO::Socket::INET.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   531
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   532
=head1 EXAMPLES
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   533
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   534
This example prints the mail domain name of the SMTP server known as mailhost:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   535
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   536
    #!/usr/local/bin/perl -w
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   537
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   538
    use Net::SMTP;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   539
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   540
    $smtp = Net::SMTP->new('mailhost');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   541
    print $smtp->domain,"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   542
    $smtp->quit;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   543
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   544
This example sends a small message to the postmaster at the SMTP server
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   545
known as mailhost:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   546
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   547
    #!/usr/local/bin/perl -w
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   548
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   549
    use Net::SMTP;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   550
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   551
    $smtp = Net::SMTP->new('mailhost');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   552
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   553
    $smtp->mail($ENV{USER});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   554
    $smtp->to('postmaster');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   555
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   556
    $smtp->data();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   557
    $smtp->datasend("To: postmaster\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   558
    $smtp->datasend("\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   559
    $smtp->datasend("A simple test message\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   560
    $smtp->dataend();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   561
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   562
    $smtp->quit;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   563
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   564
=head1 CONSTRUCTOR
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   565
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   566
=over 4
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   567
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   568
=item new Net::SMTP [ HOST, ] [ OPTIONS ]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   569
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   570
This is the constructor for a new Net::SMTP object. C<HOST> is the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   571
name of the remote host to which an SMTP connection is required.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   572
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   573
If C<HOST> is an array reference then each value will be attempted
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   574
in turn until a connection is made.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   575
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   576
If C<HOST> is not given, then the C<SMTP_Host> specified in C<Net::Config>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   577
will be used.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   578
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   579
C<OPTIONS> are passed in a hash like fashion, using key and value pairs.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   580
Possible options are:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   581
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   582
B<Hello> - SMTP requires that you identify yourself. This option
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   583
specifies a string to pass as your mail domain. If not
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   584
given a guess will be taken.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   585
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   586
B<LocalAddr> and B<LocalPort> - These parameters are passed directly
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   587
to IO::Socket to allow binding the socket to a local port.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   588
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   589
B<Timeout> - Maximum time, in seconds, to wait for a response from the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   590
SMTP server (default: 120)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   591
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   592
B<ExactAddresses> - If true the all ADDRESS arguments must be as
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   593
defined by C<addr-spec> in RFC2822. If not given, or false, then
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   594
Net::SMTP will attempt to extract the address from the value passed.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   595
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   596
B<Debug> - Enable debugging information
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   597
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   598
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   599
Example:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   600
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   601
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   602
    $smtp = Net::SMTP->new('mailhost',
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   603
			   Hello => 'my.mail.domain'
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   604
			   Timeout => 30,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   605
                           Debug   => 1,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   606
			  );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   607
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   608
=back
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   609
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   610
=head1 METHODS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   611
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   612
Unless otherwise stated all methods return either a I<true> or I<false>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   613
value, with I<true> meaning that the operation was a success. When a method
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   614
states that it returns a value, failure will be returned as I<undef> or an
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   615
empty list.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   616
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   617
=over 4
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   618
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   619
=item banner ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   620
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   621
Returns the banner message which the server replied with when the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   622
initial connection was made.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   623
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   624
=item domain ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   625
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   626
Returns the domain that the remote SMTP server identified itself as during
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   627
connection.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   628
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   629
=item hello ( DOMAIN )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   630
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   631
Tell the remote server the mail domain which you are in using the EHLO
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   632
command (or HELO if EHLO fails).  Since this method is invoked
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   633
automatically when the Net::SMTP object is constructed the user should
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   634
normally not have to call it manually.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   635
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   636
=item etrn ( DOMAIN )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   637
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   638
Request a queue run for the DOMAIN given.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   639
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   640
=item auth ( USERNAME, PASSWORD )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   641
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   642
Attempt SASL authentication.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   643
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   644
=item mail ( ADDRESS [, OPTIONS] )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   645
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   646
=item send ( ADDRESS )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   647
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   648
=item send_or_mail ( ADDRESS )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   649
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   650
=item send_and_mail ( ADDRESS )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   651
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   652
Send the appropriate command to the server MAIL, SEND, SOML or SAML. C<ADDRESS>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   653
is the address of the sender. This initiates the sending of a message. The
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   654
method C<recipient> should be called for each address that the message is to
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   655
be sent to.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   656
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   657
The C<mail> method can some additional ESMTP OPTIONS which is passed
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   658
in hash like fashion, using key and value pairs.  Possible options are:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   659
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   660
 Size        => <bytes>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   661
 Return      => "FULL" | "HDRS"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   662
 Bits        => "7" | "8" | "binary"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   663
 Transaction => <ADDRESS>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   664
 Envelope    => <ENVID>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   665
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   666
The C<Return> and C<Envelope> parameters are used for DSN (Delivery
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   667
Status Notification).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   668
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   669
=item reset ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   670
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   671
Reset the status of the server. This may be called after a message has been 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   672
initiated, but before any data has been sent, to cancel the sending of the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   673
message.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   674
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   675
=item recipient ( ADDRESS [, ADDRESS [ ...]] [, OPTIONS ] )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   676
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   677
Notify the server that the current message should be sent to all of the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   678
addresses given. Each address is sent as a separate command to the server.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   679
Should the sending of any address result in a failure then the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   680
process is aborted and a I<false> value is returned. It is up to the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   681
user to call C<reset> if they so desire.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   682
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   683
The C<recipient> method can some additional OPTIONS which is passed
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   684
in hash like fashion, using key and value pairs.  Possible options are:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   685
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   686
 Notify    =>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   687
 SkipBad   => ignore bad addresses
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   688
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   689
If C<SkipBad> is true the C<recipient> will not return an error when a
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   690
bad address is encountered and it will return an array of addresses
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   691
that did succeed.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   692
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   693
  $smtp->recipient($recipient1,$recipient2);  # Good
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   694
  $smtp->recipient($recipient1,$recipient2, { SkipBad => 1 });  # Good
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   695
  $smtp->recipient("$recipient,$recipient2"); # BAD   
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   696
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   697
=item to ( ADDRESS [, ADDRESS [...]] )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   698
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   699
=item cc ( ADDRESS [, ADDRESS [...]] )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   700
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   701
=item bcc ( ADDRESS [, ADDRESS [...]] )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   702
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   703
Synonyms for C<recipient>.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   704
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   705
=item data ( [ DATA ] )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   706
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   707
Initiate the sending of the data from the current message. 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   708
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   709
C<DATA> may be a reference to a list or a list. If specified the contents
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   710
of C<DATA> and a termination string C<".\r\n"> is sent to the server. And the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   711
result will be true if the data was accepted.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   712
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   713
If C<DATA> is not specified then the result will indicate that the server
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   714
wishes the data to be sent. The data must then be sent using the C<datasend>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   715
and C<dataend> methods described in L<Net::Cmd>.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   716
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   717
=item expand ( ADDRESS )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   718
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   719
Request the server to expand the given address Returns an array
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   720
which contains the text read from the server.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   721
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   722
=item verify ( ADDRESS )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   723
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   724
Verify that C<ADDRESS> is a legitimate mailing address.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   725
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   726
=item help ( [ $subject ] )
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   727
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   728
Request help text from the server. Returns the text or undef upon failure
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   729
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   730
=item quit ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   731
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   732
Send the QUIT command to the remote SMTP server and close the socket connection.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   733
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   734
=back
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   735
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   736
=head1 ADDRESSES
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   737
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   738
Net::SMTP attempts to DWIM with addresses that are passed. For
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   739
example an application might extract The From: line from an email
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   740
and pass that to mail(). While this may work, it is not reccomended.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   741
The application should really use a module like L<Mail::Address>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   742
to extract the mail address and pass that.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   743
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   744
If C<ExactAddresses> is passed to the contructor, then addresses
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   745
should be a valid rfc2821-quoted address, although Net::SMTP will
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   746
accept accept the address surrounded by angle brackets.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   747
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   748
 funny user@domain      WRONG
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   749
 "funny user"@domain    RIGHT, recommended
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   750
 <"funny user"@domain>  OK
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   751
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   752
=head1 SEE ALSO
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   753
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   754
L<Net::Cmd>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   755
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   756
=head1 AUTHOR
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   757
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   758
Graham Barr <gbarr@pobox.com>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   759
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   760
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   761
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   762
Copyright (c) 1995-1997 Graham Barr. All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   763
This program is free software; you can redistribute it and/or modify
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   764
it under the same terms as Perl itself.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   765
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   766
=for html <hr>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   767
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   768
I<$Id: //depot/libnet/Net/SMTP.pm#31 $>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   769
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   770
=cut