Re: pacth for MIME::Lite

2010-10-11 Thread fakessh
hello pep network


perl gurus have certainly already found the bug
you would be very nice if you help me find the bug


help me This is the challenge


Le mardi 05 octobre 2010 à 11:21 +0200, fakessh a écrit :
 hello guys
 i am french
 i am love Perl
 i am good in Perl
 3 level actually for perlmonks
 
 i wrote a patch for MIME::Lite
 i quote
 
 ~]# cat   mimelitefinal.patch 
 --- Desktop/MIME-Lite-3.027/lib/MIME/Lite.pm2009-10-10
 04:04:04.0 +0200
 +++ /usr/lib/perl5/site_perl/5.8.8/MIME/Lite.pm 2010-09-16
 20:11:16.0 +0200
 @@ -404,6 +404,8 @@
sendmail  = [$SENDMAIL ? $SENDMAIL -t -oi -oem : undef],
smtp  = [],
sub   = [],
 +  tls   = [],
 +  ssl   = [],
  );
  
  ### Boundary counter:
 @@ -2562,25 +2564,23 @@
  
  if ( ref($self) ) {### instance method:
  my ( $method, @args );
 -if (@_) {  ### args; use them just this once
 -$method = 'send_by_' . $meth;
 +if (@_) {   ### no args; use defaults
 +$method = 'send_by_'.$meth;
  @args   = @_;
 -} else {   ### no args; use defaults
 +} elsif (@_) {
 +my @old = ( $Sender, @{ $SenderArgs{$Sender} } );
 +$Sender  = $meth;
 +$SenderArgs{$Sender} = [...@_];   ### remaining args
 +return @old;
 +   } elsif (@_) {
  $method = send_by_$Sender;
  @args   = @{ $SenderArgs{$Sender} || [] };
 -}
 +   }
  $self-verify_data if $AUTO_VERIFY;### prevents missing
 parts!
  Carp::croak Unknown send method '$meth' unless
 $self-can($method);
  return $self-$method(@args);
 -} else {   ### class method:
 -if (@_) {
 -my @old = ( $Sender, @{ $SenderArgs{$Sender} } );
 -$Sender  = $meth;
 -$SenderArgs{$Sender} = [...@_];   ### remaining args
 -return @old;
 -} else {
 +} else {
  Carp::croak class method send must have HOW... arguments
 \n;
 -}
  }
  }
  
 @@ -2829,7 +2829,7 @@
  my @_mail_opts = qw( Size Return Bits Transaction Envelope );
  my @_recip_opts= qw( SkipBad );
  my @_net_smtp_opts = qw( Hello LocalAddr LocalPort Timeout
 - Port ExactAddresses Debug );
 + Port User Password ExactAddresses Debug );
  # internal:  qw( NoAuth AuthUser AuthPass To From Host);
  
  sub __opts {
 @@ -2872,7 +2872,7 @@
  if ($smtp-supports('AUTH',500,[Command unknown: 'AUTH'])) {
  $smtp-auth( $args{AuthUser}, $args{AuthPass} )
  or die SMTP auth() command failed: $!\n
 -   . $smtp-message . \n;
 +   . $smtp  . \n;
  } else {
  die SMTP auth() command not supported on $hostname\n;
  }
 @@ -2893,14 +2893,14 @@
  # Send the data
  $smtp-data()
or die SMTP data() command failed: $!\n
 - . $smtp-message . \n;
 + . $smtp  . \n;
  $self-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
 +  . $smtp 
. This probably represents a problem with newline encoding ;
  
  # terminate the session
 @@ -2908,6 +2908,121 @@
  
  return $self-{last_send_successful} = 1;
  }
 +sub send_by_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($field);
 +}
 +}
 +  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-Path') );
 +$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 . \n;
 +
 +# Send the recipients command
 +%opts = __opts( \%args, @_recip_opts);
 +$smtp-to( @{ $args{To} }, %opts ? \%opts : () )
 +  or die SMTP recipient() command failed: $!\n
 +  . $smtp . \n;
 +
 +# Send the data

Re: pacth for MIME::Lite

2010-10-08 Thread fakessh
hello pep network

did you apply the patch and did you find the problem of encoding
characters in the lib MIME:: Lite

I thank you for all your possible returns

Le mardi 05 octobre 2010 à 11:21 +0200, fakessh a écrit :
 hello guys
 i am french
 i am love Perl
 i am good in Perl
 3 level actually for perlmonks
 
 i wrote a patch for MIME::Lite
 i quote
 
 ~]# cat   mimelitefinal.patch 
 --- Desktop/MIME-Lite-3.027/lib/MIME/Lite.pm2009-10-10
 04:04:04.0 +0200
 +++ /usr/lib/perl5/site_perl/5.8.8/MIME/Lite.pm 2010-09-16
 20:11:16.0 +0200
 @@ -404,6 +404,8 @@
sendmail  = [$SENDMAIL ? $SENDMAIL -t -oi -oem : undef],
smtp  = [],
sub   = [],
 +  tls   = [],
 +  ssl   = [],
  );
  
  ### Boundary counter:
 @@ -2562,25 +2564,23 @@
  
  if ( ref($self) ) {### instance method:
  my ( $method, @args );
 -if (@_) {  ### args; use them just this once
 -$method = 'send_by_' . $meth;
 +if (@_) {   ### no args; use defaults
 +$method = 'send_by_'.$meth;
  @args   = @_;
 -} else {   ### no args; use defaults
 +} elsif (@_) {
 +my @old = ( $Sender, @{ $SenderArgs{$Sender} } );
 +$Sender  = $meth;
 +$SenderArgs{$Sender} = [...@_];   ### remaining args
 +return @old;
 +   } elsif (@_) {
  $method = send_by_$Sender;
  @args   = @{ $SenderArgs{$Sender} || [] };
 -}
 +   }
  $self-verify_data if $AUTO_VERIFY;### prevents missing
 parts!
  Carp::croak Unknown send method '$meth' unless
 $self-can($method);
  return $self-$method(@args);
 -} else {   ### class method:
 -if (@_) {
 -my @old = ( $Sender, @{ $SenderArgs{$Sender} } );
 -$Sender  = $meth;
 -$SenderArgs{$Sender} = [...@_];   ### remaining args
 -return @old;
 -} else {
 +} else {
  Carp::croak class method send must have HOW... arguments
 \n;
 -}
  }
  }
  
 @@ -2829,7 +2829,7 @@
  my @_mail_opts = qw( Size Return Bits Transaction Envelope );
  my @_recip_opts= qw( SkipBad );
  my @_net_smtp_opts = qw( Hello LocalAddr LocalPort Timeout
 - Port ExactAddresses Debug );
 + Port User Password ExactAddresses Debug );
  # internal:  qw( NoAuth AuthUser AuthPass To From Host);
  
  sub __opts {
 @@ -2872,7 +2872,7 @@
  if ($smtp-supports('AUTH',500,[Command unknown: 'AUTH'])) {
  $smtp-auth( $args{AuthUser}, $args{AuthPass} )
  or die SMTP auth() command failed: $!\n
 -   . $smtp-message . \n;
 +   . $smtp  . \n;
  } else {
  die SMTP auth() command not supported on $hostname\n;
  }
 @@ -2893,14 +2893,14 @@
  # Send the data
  $smtp-data()
or die SMTP data() command failed: $!\n
 - . $smtp-message . \n;
 + . $smtp  . \n;
  $self-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
 +  . $smtp 
. This probably represents a problem with newline encoding ;
  
  # terminate the session
 @@ -2908,6 +2908,121 @@
  
  return $self-{last_send_successful} = 1;
  }
 +sub send_by_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($field);
 +}
 +}
 +  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-Path') );
 +$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 . \n;
 +
 +# Send the recipients command
 +%opts = __opts( \%args, @_recip_opts);
 +$smtp-to( @{ $args{To} }, %opts ? \%opts : () )
 +  or die SMTP recipient() command failed: $!\n
 +  . $smtp . \n;
 +
 +# Send

how to add a proper attachment to an email message

2010-05-13 Thread fakessh
hello list
hello all reader
hello pep network


my question is simple
how to add a proper attachment to an email message
I use as main modules use Email::Send and use Email::Simple::Creator

thanks for all your feedbacks
thanks for advice


Re: I do not understand the error CGI that I get CGI using Email:: Simple

2010-05-04 Thread fakessh
On Tue, 4 May 2010 07:41:26 -0400, Ricardo Signes
perl@rjbs.manxome.org wrote:
 * fakessh fake...@fakessh.eu [2010-05-03T20:55:20]
 click error
 
 
 when I am not MIME:: Lite 
 I find myself with a CGI error in httpd and browser. 
 I do not understand why
 
 What's the error?


I have a CGI error logs in httpd
[Tue May 04 14:14:59 2010] [error] [client 90.30.250.62] ModSecurity:
Unable to retrieve collection (name ip, key 90.30.250.62). Use
SecDataDir to define data directory first. [hostname mail.fakessh.eu]
[uri /webmail/] [unique_id qIh7H1diuugAAB1JIxoD]
[Tue May 04 14:15:03 2010] [error] [client 90.30.250.62] ModSecurity:
Unable to retrieve collection (name global, key global). Use SecDataDir
to define data directory first. [hostname mail.fakessh.eu] [uri
/webmail/] [unique_id qM1ueFdiuugAAB1CI9oB]
[Tue May 04 14:15:03 2010] [error] [client 90.30.250.62] ModSecurity:
Unable to retrieve collection (name ip, key 90.30.250.62). Use
SecDataDir to define data directory first. [hostname mail.fakessh.eu]
[uri /webmail/] [unique_id qM1ueFdiuugAAB1CI9oB]
[Tue May 04 14:15:04 2010] [error] [client 90.30.250.62] ModSecurity: Rule
execution error - PCRE limits exceeded (-8): (null). [hostname
mail.fakessh.eu] [uri /webmail/] [unique_id qM1ueFdiuugAAB1CI9oB]
[Tue May 04 14:15:10 2010] [error] [client 90.30.250.62] ModSecurity:
Unable to retrieve collection (name global, key global). Use SecDataDir
to define data directory first. [hostname mail.fakessh.eu] [uri
/webmail/] [unique_id q...@1diuugaab1xql4h]
[Tue May 04 14:15:10 2010] [error] [client 90.30.250.62] ModSecurity:
Unable to retrieve collection (name ip, key 90.30.250.62). Use
SecDataDir to define data directory first. [hostname mail.fakessh.eu]
[uri /webmail/] [unique_id q...@1diuugaab1xql4h]
[Tue May 04 14:15:10 2010] [error] [client 90.30.250.62] ModSecurity: Rule
execution error - PCRE limits exceeded (-8): (null). [hostname
mail.fakessh.eu] [uri /webmail/] [unique_id q...@1diuugaab1xql4h]
[Tue May 04 14:15:11 2010] [error] [client 90.30.250.62] Can't use string
(fake...@fakessh.eu) as a HASH ref while strict refs in use at
/usr/lib/perl5/vendor_perl/5.8.8/Email/Simple.pm line 100., referer:
http://mail.fakessh.eu/webmail/?encrypted=53616c7465645f5f7ac973deeb4df2fdbaab1fae755a502b6ab45f43258e8499d0af88df74e960eadfe072d0579fcea4b319e8f43a731e6b8e9a03a2a5efd00f7076eeb27aaf7b7f5eec059beaf0a3fb12e53bb9efa66a2bf141d5a224246d332eb35f5620c49f4a45c0a3a2124ea94e3dba89fb95ce9a5a799ec809951fa5e04d1dbe2b2616c2eed29d8b139792f9d884aeb2265725aa4c3309f51495c5afe37e41a2a438b315cd
[Tue May 04 14:15:11 2010] [error] [client 90.30.250.62] Premature end of
script headers: webmail.pl, referer:
http://mail.fakessh.eu/webmail/?encrypted=53616c7465645f5f7ac973deeb4df2fdbaab1fae755a502b6ab45f43258e8499d0af88df74e960eadfe072d0579fcea4b319e8f43a731e6b8e9a03a2a5efd00f7076eeb27aaf7b7f5eec059beaf0a3fb12e53bb9efa66a2bf141d5a224246d332eb35f5620c49f4a45c0a3a2124ea94e3dba89fb95ce9a5a799ec809951fa5e04d1dbe2b2616c2eed29d8b139792f9d884aeb2265725aa4c3309f51495c5afe37e41a2a438b315cd
^X


 
  package PerlWebmail::Message;
  use base qw(MIME::Lite);
  use base qw(Email::Simple);
 
 Extending both those classes at once seems doomed to fail a lot.
 

I can well use Email:: Simple in a CGI

  sub mail 
  {
  my ($self, $message) = @_;
  my $obj = Email::Simple-new($message);
  print $obj-as_string;
  $Self-new;
  }
 
 You said $Self instead of $self.

typographical error 
the correcting operation in the class is ok


I do not understand the error CGI that I get CGI using Email:: Simple

2010-05-03 Thread fakessh
hello all
hello pep network
hello guru of perl

This class is named message
this:

[r...@r13151 ~]# cat /usr/lib/perl5/site_perl/5.8.8/PerlWebmail/Message.pm
package PerlWebmail::Message;
use base qw(MIME::Lite);
use base qw(Email::Simple);

sub new
{
  my $class = shift;

  my $self = $class-SUPER::new(@_);

  return $self;
}

sub mail 
{
my ($self, $message) = @_;
my $obj = Email::Simple-new($message);
print $obj-as_string;
$Self-new;

}

1;




Re: I do not understand the error CGI that I get CGI using Email:: Simple

2010-05-03 Thread fakessh
click error


when I am not MIME:: Lite 
I find myself with a CGI error in httpd and browser. 
I do not understand why


On Tue, 04 May 2010 02:50:58 +0200, fakessh fake...@fakessh.eu wrote:
 hello all
 hello pep network
 hello guru of perl
 
 This class is named message
 this:
 
 [r...@r13151 ~]# cat
/usr/lib/perl5/site_perl/5.8.8/PerlWebmail/Message.pm
 package PerlWebmail::Message;
 use base qw(MIME::Lite);
 use base qw(Email::Simple);
 
 sub new
 {
   my $class = shift;
 
   my $self = $class-SUPER::new(@_);
 
   return $self;
 }
 
 sub mail 
 {
 my ($self, $message) = @_;
 my $obj = Email::Simple-new($message);
 print $obj-as_string;
 $Self-new;
 
 }
 
 1;


post test

2010-04-17 Thread fakessh
hello 

post test




how to encode correctly email

2010-04-17 Thread fakessh
hello list
hello guru of perl
hello all users of this list

I work a little on the webmail of perlwebmail @ jaos
who suffers from a bad encoding of messages in the interface

@jaos impleùente encoding like that

package PerlWebmail::Message;
use base qw(MIME::Lite);

my $crlf = qr/\x0a\x0d|\x0d\x0a|\x0a|\x0d/; #I know this is not correct 
  #Unix uses \x0a for line endings.
Windows uses \x0d\x0a. MacOS
  #(IIRC) uses \x0d. Which OS uses
\x0a\x0d?


my $quote_prefix = '';

sub new
{
  my $class = shift;

  unless (grep { /^Encoding$/ } @_) {  #to raise /^Encoding$/i.
push @_, ('Encoding','8bit');
  }

  my $self = $class-SUPER::new(@_);

  $self-replace('X-Mailer','PerlWebmail (http://software.jaos.org)');

  return $self;
}

sub from
{
  my ($self, $from) = @_;
  if ($from) {
$self-add('To',$from);
  }
  $self-get('From');
}

sub to
{
  my ($self, $to) = @_;
  if ($to) {
$self-add('To',$to);
  }
  $self-get('To');
}

sub cc
{
  my ($self, $cc) = @_;
  if ($cc) {
$self-add('Cc',$cc);
  }
  $self-get('Cc');
}

sub bcc
{
  my ($self, $bcc) = @_;
  if ($cc) {
$self-add('Bcc',$bcc);
  }
  $self-get('Bcc');
}

sub subject
{
  my ($self, $subject) = @_;
  if ($subject) {
$self-replace('Subject',$subject);
  }
  $self-get('Subject');
}

sub body
{
  my ($self, $body) = @_;
  if ($body) {
$self-build( Type = 'TEXT', Encoding = '8bit', Data = $body);
  }
  $self-body_as_string;
}

sub asString
{
  shift-as_string;
}

#my $crlf = qr/\x0a\x0d|\x0d\x0a|\x0a|\x0d/;
#sub _strip_sig { reverse +(split /$crlf\s*--$crlf/o, reverse(pop), 2)[1]
}

sub quote
{
  my $body = shift;
  $body =~ s/($crlf)/$1$quote_prefix /g;
  \n\n$quote_prefix $body;
}

1;


I think a better realize being an encoding like this
#!/usr/bin/perl

use Encode qw(all);
my $ENC_ASCII = 'ASCII';
# When all other defaults are exhausted, use UTF-8
my $result = undef;
      eval{
              $result = Encode::encode_utf8($text);
                      };
                      if($@){
                      }
              if($result){
   return $result;
      }
# Something is seriously wrong if we get to here
 return encode($ENC_ASCII, $text, undef);


ou 

# IO layer: $handle now decodes all strings upon reading
open my $handle, ':encoding(UTF-8)', $file;

ou 
# same
binmode $handle, ':encoding(UTF-8)';


how do you recommend to encode messages as much as input output

thanks for advice
thanks for all your feddbacks


ps : http://minilien.fr/a0lhww


post test

2010-04-08 Thread fakessh
post test


post test

2010-04-04 Thread fakessh
post test 


/fakessh/