Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

when I indicate Port => 587 in the constructor. the mail is sent through the port 25 when the same

i modified the patch .I can reproduce the error. I integrated the new lib in perlwebmail of jaos, and mail out each time with port 25

[root@r13151 ~]# diff -r /usr/lib/perl5/vendor_perl/5.8.8/MIME/Lite.pm + MIME-Lite-3.027/lib/MIME/Lite.pm 347c347 < $VERSION = '3.025'; --- > $VERSION = '3.027'; 407d406 < tls => [], 440c439 < if ( !$PARANOID and eval "require MIME::Types; MIME::Types->VERSION( +1.004);" ) { --- > if ( !$PARANOID and eval "require MIME::Types; MIME::Types->VERSION( +1.28);" ) { 2569,2570c2568 < } < if (@_) { ### no args; use defaults --- > } else { ### no args; use defaults 2573,2575d2570 < } else { < $method = 'send_by_smtp_' . $meth; < @args = @{ $SenderArgs{$Sender} || [] }; 2844,2902d2838 < sub send_by_smtp_tls { < require Net::SMTP::TLS; < my ($self,$hostname,%args) = @_; < # We may need the "From:" and "To:" headers to pass to the < # SMTP mailer also. < $self->{last_send_successful}=0; < < my @hdr_to = extract_only_addrs( scalar $self->get('To') ); < if ($AUTO_CC) { < foreach my $field (qw(Cc Bcc)) { < push @hdr_to, extract_only_addrs($_) for $self->get($fie +ld); < } < } < Carp::croak "send_by_smtp: nobody to send to for host '$hostname'? +!\n" < unless @hdr_to; < < $args{To} ||= \@hdr_to; < $args{From} ||= extract_only_addrs( scalar $self->get('Return-Pa +th') ); < $args{From} ||= extract_only_addrs( scalar $self->get('From') ) +; < < # Create SMTP client. < # MIME::Lite::SMTP is just a wrapper giving a print method < # to the SMTP object. < < my %opts = __opts(\%args, @_net_smtp_opts); < my $smtp = MIME::Lite::SMTP::TLS->new( $hostname, %opts ) < or Carp::croak "SMTP Failed to connect to mail server: $!\n"; < < # Send the mail command < %opts = __opts( \%args, @_mail_opts); < $smtp->mail( $args{From}, %opts ? \%opts : () ) < or die "SMTP mail() command failed: $!\n" < . $smtp->message . "\n"; < < # Send the recipients command < %opts = __opts( \%args, @_recip_opts); < $smtp->to( @{ $args{To} }, %opts ? \%opts : () ) < or die "SMTP recipient() command failed: $!\n" < . $smtp->message . "\n"; < < # Send the data < $smtp->data < or die "SMTP data() command failed: $!\n" < . $smtp->message . "\n"; < $self->datasend( eval {print_for_smtp($smtp)}); < < # Finish the mail < $smtp->dataend() < or Carp::croak "Net::CMD (Net::SMTP) DATAEND command failed.\n +" < . "Last server message was:" < . $smtp->message < . "This probably represents a problem with newline encoding "; < < # terminate the session < $smtp->quit; < < return $self->{last_send_successful} = 1; < } < 2930a2867 > 2974a2912,2942 > =item send_by_testfile FILENAME > > I<Instance method.> > Print message to a file (namely FILENAME), which will default to > mailer.testfile > If file exists, message will be appended. > > =cut > > sub send_by_testfile { > my $self = shift; > > ### Use the default filename... > my $filename = 'mailer.testfile'; > > if ( @_ == 1 and !ref $_[0] ) { > ### Use the given filename if given... > $filename = shift @_; > Carp::croak "no filename given to send_by_testfile" unless $file +name; > } > > ### Do it: > local *FILE; > open FILE, ">> $filename" or Carp::croak "open $filename: $!\n"; > $self->print( \*FILE ); > close FILE; > my $return = ( ( $? >> 8 ) ? undef: 1 ); > > return $self->{last_send_successful} = $return; > } > 3025d2992 < require Net::SMTP::TLS, 3164,3204d3130 < package MIME::Lite::SMTP::TLS; < < #============================================================ < # This class just adds a print() method to Net::SMTP. < # Notice that we don't use/require it until it's needed! < < use strict; < use vars qw( @ISA ); < @ISA = qw(Net::SMTP::TLS); < < # some of the below is borrowed from Data::Dumper < my %esc = ( "\a" => "\\a", < "\b" => "\\b", < "\t" => "\\t", < "\n" => "\\n", < "\f" => "\\f", < "\r" => "\\r", < "\e" => "\\e", < ); < < sub _hexify { < local $_ = shift; < my @split = m/(.{1,16})/gs; < foreach my $split (@split) { < ( my $txt = $split ) =~ s/([\a\b\t\n\f\r\e])/$esc{$1}/sg; < $split =~ s/(.)/sprintf("%02X ",ord($1))/sge; < print STDERR "M::L >>> $split : $txt\n"; < } < } < < sub print { < my $smtp = shift; < $MIME::Lite::DEBUG and _hexify( join( "", @_ ) ); < $smtp->datasend(@_) < or Carp::croak( "Net::CMD (Net::SMTP) DATASEND command faile +d.\n" < . "Last server message was:" < . $smtp->message < . "This probably represents a problem with new +line encoding " ); < } < #============================================================ < 3717c3643 < Version: 3.01_06 (Dev Test Release) --- > Version: 3.027

In reply to Re^2: add to MIME::Lite support for smtp tls on port 587 by swilting
in thread add to MIME::Lite support for smtp tls on port 587 by swilting

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (11)
    As of 2014-09-30 21:11 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (384 votes), past polls