Bod has asked for the wisdom of the Perl Monks concerning the following question:
We send automated emails with things like registration verifications automatically. We user MIME::Lite to do the sending and use the default send mechanism which is sendmail as it is a Linux server.
But we are having some issues with deliverability. So, I decided to switch to using SMTP instead to see if that works more reliably. To send via SMTP MIME::Lite uses Net::SMTP which in turn requires MIME::Base64. This last module is XS and I don't have it installed on the shared hosting.
We use Net::SMTP elsewhere to send lots of emails so I have looked at what I did in the past to get around this problem. It turns out that I created a new module that inherits from Net::SMTP and overrides the auth method. This works fine as we always send through the same SMTP server with the same authentication. Doing the same will be fine for the MIME::Lite setup.
Like this:
package Mail::SMTP; require Net::SMTP; $VERSION="1.0"; @ISA=qw(Net::SMTP); sub auth { my $self = shift; my $code; my $CMD_MORE = 3; my $CMD_OK = 2; my @cmd = ("AUTH LOGIN"); push @cmd, 'xxxxx='; # Base64 encoded username while (($code = $self->command(@cmd)->response()) == $CMD_MORE) { @cmd = ('xxxxx='); # Base64 encoded password } $code == $CMD_OK; } 1;
But, how can I easily get MIME::Lite to use the new module inherited from New::SMTP?
I could created a new module that inherits from MIME::Lite and just override the send_by_smtp with the only change being the require file it calls. But that doesn't seen a very elegant solution!
Is there some way to instead put a new version of Net::SMTP in a directory relative to my script and get MIME::Lite to use that? If so, how can I inherit from a module of the same name (but a different path) as the new module?
Or is there a 'better' solution I am missing?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Replacing a module dependency
by haukex (Archbishop) on Apr 27, 2022 at 05:32 UTC | |
by Bod (Parson) on Apr 27, 2022 at 11:06 UTC | |
|
Re: Replacing a module dependency
by kcott (Archbishop) on Apr 27, 2022 at 06:47 UTC | |
by Bod (Parson) on Apr 27, 2022 at 10:54 UTC | |
|
Re: Replacing a module dependency
by hippo (Archbishop) on Apr 27, 2022 at 09:42 UTC | |
by haukex (Archbishop) on Apr 27, 2022 at 10:20 UTC | |
|
Re: Replacing a module dependency
by Anonymous Monk on Apr 27, 2022 at 09:47 UTC | |
by Bod (Parson) on Apr 27, 2022 at 11:17 UTC |