在没有安装 sendmail 且没有任何邮件模块的情况下使用 Perl 发送电子邮件

发布于 2024-10-15 01:51:59 字数 407 浏览 5 评论 0原文

我正在制作一个露营网站,我需要从 Perl 发送一封电子邮件。但是,服务器上未安装 sendmail,并且这些是唯一安装的 Perl 模块:

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

还有办法从 Perl 脚本发送电子邮件吗?


我已经给网络托管公司打电话询问此事,但似乎他们甚至不知道 Perl 是什么。更不用说sendmail了。这家公司自称为网络托管公司。

I am making a website 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

放血 2024-10-22 01:51:59

这个问题可以更一般地重新表述为“我如何在 Perl 中做一些需要我的系统上未安装的模块的事情,并且我没有对此框的根控制权,并且系统管理员不能或不会合作?”

用一句话来说,最好的答案是“使用 local::lib”,但是您可以在 Matt Trout 的博客文章 “但是我无法使用 CPAN!”

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!".

权谋诡计 2024-10-22 01:51:59

Net::SMTP 是一个核心模块,应该包含在 Perl 的任何安装中。模块文档显示了发送电子邮件的简单示例。使用“perldoc Net::SMTP”查看它是否存在并查看示例。

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.

苏璃陌 2024-10-22 01:51:59

除了明显的答案(“更改您的托管服务商”)之外,当然,您可以用纯 Perl 编写 SMTP 客户端。最简单的方法是将 Net::SMTP 集成到您的 Perl 代码中,或者,对于一些更奇特的东西,将 Email::Send 集成到您的 Perl 代码中。纯 Perl 模块不需要任何特殊的安装过程。但从头开始编写 SMTP 客户端也不难。

无论您选择哪种方式,请确保在失败后一小时左右插入某种重试方法。否则,您的网站将属于那些根本无法使用灰名单向任何人发送邮件的网站。

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.

戒ㄋ 2024-10-22 01:51:59

寻找新的托管公司?或者至少将您的电子邮件表格托管在其他地方?

如果您有权访问 shell,您应该能够在本地文件夹中安装模块。除非您甚至可以在其他机器上“安装”纯 perl 模块,然后通过 FTP 将生成的模块复制到主机。

至于您应该使用的模块: MIME::Lite 可以使用 SMTP 发送,因此不需要 sendmail。它也全部是 Perl(没有 C 后端),所以你可能可以做到这一点。

如果以上方法都不起作用,您可以直接连接到 SMTP 服务器,但这相当复杂,尤其是当您想发送附件时

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

夏有森光若流苏 2024-10-22 01:51:59

如果您无法安装任何其他模块,最简单的方法是将 sendmail 模块的代码源集成到您的项目中,但您还必须检查 sendmail 模块的许可证是否允许您这样做。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文