jdtoronto has asked for the wisdom of the Perl Monks concerning the following question:

Esteemed Monks,

I have a chunk of code sending email with MIME attachments. It currently uses MIME::Entity, which uses Mail::Internet which ultimately uses Net::SMTP to send the email. Unfortunately Net::SMTP doesn't handle SMTP AUTHentication, so I need to use Net::SMTP_auth. I have emailed the author to ask if he would change Mail::Internet.

I know I can hack a version of the module on my machine, but is there a 'protection' mechanism that would allow me to detect if I do something stupid in the future like loading a new, un hacked version of Mail::Internet?

jdtoronto

Replies are listed 'Best First'.
Re: SMTP authorisation for MIME emails.
by mda2 (Hermit) on Aug 22, 2006 at 14:51 UTC
    Net::SMTP implements Auth, but needs Authen::SASL See methods and samples on pod or code:

    ... cut ... sub auth { my ($self, $username, $password) = @_; eval { require MIME::Base64; require Authen::SASL; } or $self->set_status(500,["Need MIME::Base64 and Authen::SASL to +do auth"]), return 0; ... cut ...

    Humm, good! Implements a convenient, test to prevent error... (can be optimized, but it's good!)

    I'm using this to send my test messages on authenticaded. .............

    --
    Marco Antonio
    Rio-PM

      Thanks mda2,

      I had seen a reference to the auth method in the POD, but when I tried it I had no luck. Seems I didn't read far enough ;)

      After looking at the source for Mail::Internet it seems the Net::SMTP object is well buried and only exists briefly within the scope of the smtpsend method. The author was very prompt in replying and I find myself agreeing with his assetion that their are better ways and this one is no longer something he is prepared to enhance. That being said I think the more appropriate approach would be to use MIME::Entity (to which I am committed) or maybe MIME::Lite to produce the MIME body and then send it explicitly using Net::SMTP.

      jdtoronto