Hello Guys!!

I'm working with MIME::Lite and qmail, right now i'm using authentification but it work some time and other not, why? becouse the server only use plain authentification but some times inform that support cram-md5.

So, exists a way to force plain method of authentification

Now i'm using this code, very simple:

#!/usr/bin/perl use strict; use warnings; use MIME::Lite; my $msg = MIME::Lite->new( From => 'from@isp.com', To => 'to@isp.com', Subject => 'Subject', Type => 'text/plain', Data => q{this's an email!!} ); $msg->send('smtp','stmp.myisp.com', AuthUser=>'user',AuthPass=> 'pass' +);

Please, note that i guest that this's the problem, becouse if i'm not wrong, the method to authentification is selected with the response of server and i can see two different response of ehlo.

the error when it fail is "authorization failed (#5.7.0)"

Ugly but functional:

#!/usr/bin/perl use strict; use warnings; use MIME::Lite; my $msg = MIME::Lite->new( From => 'from@isp.com', To => 'to@isp.com', Subject => 'Subject', Type => 'text/plain', Data => q{this's an email!!} ); my $smtp = My::SMTP->new('stmp.isp.com', Debug => 4) or die $!; $smtp->auth('user','pass'); $smtp->mail('from@isp.com'); $smtp->to('to@isp.com'); $smtp->data(); $smtp->datasend($msg->as_string()); $smtp->dataend(); $smtp->quit; package My::SMTP; use strict; use warnings; use base qw(Net::SMTP); use Net::Cmd; our $VERSION = 0.01; sub auth { my ($self, $username, $password) = @_; eval { require MIME::Base64; require Authen::SASL; } or $self->set_status(500, ["Need MIME::Base64 and Authen::SASL tod +o auth"]), return 0; my $mechanisms = 'PLAIN'; return unless defined $mechanisms; my $sasl; if (ref($username) and UNIVERSAL::isa($username, 'Authen::SASL')) { $sasl = $username; $sasl->mechanism($mechanisms); } else { die "auth(username, password)" if not length $username; $sasl = Authen::SASL->new( mechanism => $mechanisms, callback => { user => $username, pass => $password, authname => $username, } ); } # We should probably allow the user to pass the host, but I don't # currently know and SASL mechanisms that are used by smtp that need + it my $client = $sasl->client_new('smtp', ${*$self}{'net_smtp_host'}, 0 +); my $str = $client->client_start; # We dont support sasl mechanisms that encrypt the socket traffic. # todo that we would really need to change the ISA hierarchy # so we dont inherit from IO::Socket, but instead hold it in an attr +ibute my @cmd = ("AUTH", $client->mechanism); my $code; push @cmd, MIME::Base64::encode_base64($str, '') if defined $str and length $str; while (($code = $self->command(@cmd)->response()) == CMD_MORE) { @cmd = ( MIME::Base64::encode_base64( $client->client_step(MIME::Base64::decode_base64(($self->messa +ge)[0])), '' ) ); } $code == CMD_OK; } 1;

In reply to Select the method of authentification on MIME::Lite by way

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.