in reply to Replacing a module dependency

MIME::Lite uses a harcoded require Net::SMTP;, so you can't tell it to use something else without modifying its code (or perhaps using an @INC hook, but that's fairly advanced and not something I'd necessarily recommend over the following). One possible approach would be to place your own version of Net::SMTP in @INC before any other paths with e.g. lib. However, this requires your version of Net::SMTP to also be called Net::SMTP, which means you'd need to copy Net::SMTP and modify it... personally, I actually think your suggestion of making a new module that inherits from MIME::Lite to be more elegant than that!

However, note in general you probably want to consider switching to one of the newer Email::* modules by RJBS, the current maintainer of MIME::Lite - the documentation of that module starts with:

MIME::Lite is not recommended by its current maintainer. There are a number of alternatives, like Email::MIME or MIME::Entity and Email::Sender, which you should probably use instead. MIME::Lite continues to accrue weird bug reports, and it is not receiving a large amount of refactoring due to the availability of better alternatives. Please consider using something else.

Replies are listed 'Best First'.
Re^2: Replacing a module dependency
by Bod (Parson) on Apr 27, 2022 at 11:06 UTC

    Thanks haukex - it turns out MIME::Base64 is there so perhaps all the overrides are not needed. See Re^2: Replacing a module dependency

    I actually think your suggestion of making a new module that inherits from MIME::Lite to be more elegant than that!

    That's very nice to hear - thanks

    However, note in general you probably want to consider switching to one of the newer Email::* modules...

    Some time ago I suggested changing away from MIME::Lite and someone more knowledgable than I (hippo I think but I'm not certain and I cannot find the node) suggested that for my needs, it was a suitable choice. The code this is used in is relatively new (less than one year) so perhaps future code should start using an alternative...

    UPDATE:
    It was Corion here -> Re^3: printing output of a perl script to the Email body