开发者

Sending an email with Perl without sendmail installed and without any mail modules

I am making a webs开发者_StackOverflow社区ite for a camping and I need to send an email from Perl. However, sendmail is not installed on the server, and these are the only Perl modules installed:

  • Class::Accessor
  • Config::Tiny
  • Math::Calc::Units
  • Nagios::Plugin
  • Params::Validate
  • Perl 5.8.8
  • TimeDate

Is there still a way to send an email form a Perl script?


I already phoned the webhosting company about this but it seems that they don't even know what Perl is. Let alone sendmail. That calls itself a webhosting company.


This question can be rephrased more generically as "how can I do something in Perl that requires a module that isn't installed on my system, and I don't have root control over this box and sysadmins can't or won't cooperate?"

In one sentence, the best answer is "use local::lib", but you can read more options in Matt Trout's blog post "But I can't use CPAN!".


Net::SMTP is a core module and should be included in any installation of Perl. The module documentation shows a simple example of sending an email. Use "perldoc Net::SMTP" to see if it is there and to see the example.


Apart from the obvious answer (“change your hoster”), sure, you can write an SMTP client in bare perl. The easiest way to do that would be to integrate Net::SMTP or, for something a little fancier, Email::Send into your perl code. Pure Perl modules don't need any special installation process. But it is not hard to write an SMTP client from scratch, either.

Whichever you choose, make sure to insert some way of retrying after an hour or so upon failure. Else, your site will go among those web sites which simply cannot send mail to anyone using greylisting.


Find a new hosting company? Or at least host your email form somewhere else?

If you have access to the shell you should be able to install a module in the local folder. Barring that you might even be able to "install" a pure perl module on some other machine and then copy the resulting module via FTP to the host.

As for the module you should use: MIME::Lite can send using SMTP so sendmail isn't required. It's also all perl (no C backend) so you can probably get that going.

If none of the above works you could connect to an SMTP server directly but that's pretty complex especially if you want to send attachments


the easy way if you cant install any other module,is to integrate the code source of your sendmail module into your project,but you have to check also if the license of sendmail module permit you to do it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜