Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

About Mail::Sender

by exilepanda (Pilgrim)
on May 25, 2012 at 04:16 UTC ( #972362=perlquestion: print w/replies, xml ) Need Help??
exilepanda has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks and Jenda,

I've done a quite uncertain hack and need advise.

I use Mail::Sender and need auth with "LOGIN" protocol. But when I use it. It's directly jump to QUIT.

After about an hour of study, I found that my mail server response me AUTH=LOGIN on say hello stage,
so that sub say_helo couldn't phrase it with $self->{'supports'} = {map {split /\s+/, $_, 2} split /\n/, $res};.

Then I added this $myMailObj->{'auth_protocols'}{LOGIN} => 1; in my script and then it runs.

But my questions are :

  • I guess this (say_helo()) is the first place where {'auth_protocols'} formed, is that correct?
  • Is that just ok at all? Any potential threats I done in this way?
  • Did I missed some interface/method I can do it in a safer manner?
  • Or am I safe by just change the \s+ to \W+?
Thank you very much!

Replies are listed 'Best First'.
Re: About Mail::Sender
by Jenda (Abbot) on Jul 17, 2012 at 07:49 UTC
    • yes
    • It should be OK this way. The say_helo() is supposed to find out what authentication protocols are supported by the server, but apparently it fails this time. I just checked and some servers return "AUTH LOGIN PLAIN" and some both "AUTH LOGIN PLAIN" and "AUTH=LOGIN PLAIN" as separate lines. I'll tweak the code to allow both whitespace and equals to separate the "AUTH" from the list.
    • No.
    • $self->{'supports'} = {map {split /(?:\s+|=)/, $_, 2} split /\n/, $res}; looks safer to me.

    According to RFC 1869 - SMTP Service Extensions (RFC1869) there should be a space, the RFC 2821 - Simple Mail Transfer Protocol says the same, but seems someone liked equals better ...

    The change will be in an upcoming version of Mail::Sender, for the time being either change the line in the module or set the $myMailObj->{'auth_protocols'}{LOGIN}. It doesn't matter much which. If you would set it for a protocol not supported by the server, the server will just report an error.

    Enoch was right!
    Enjoy the last years of Rome.

      Thanks man! I've made one simple wrapper class with optional protocol overrides ( plus some lazy methods ). I love your modules and looks forward for your update. :-)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://972362]
Approved by kcott
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2016-10-21 14:53 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (289 votes). Check out past polls.