在没有电子邮件的情况下在 ruby​​ 上使用电子邮件

发布于 2024-11-26 15:04:45 字数 256 浏览 1 评论 0原文

我想发送电子邮件,而无需设置外部电子邮件帐户,也无需设置自己的服务器。理想情况下,我不需要做任何事情,只需将代码输入 ruby​​ 命令即可。

有什么办法可以做到这一点吗?

我找不到在 ruby​​ 上使用电子邮件的清晰分步指南,有人可以为我指出正确的方向吗?请假设我什么都不知道。谢谢。我没有在 Rails 上使用 ruby​​。 :-)

我已经尝试过 pony,但似乎我需要一封电子邮件来发送来自...的消息?我想直接从 ruby​​ 发送消息。

I would like to send an email without having to set up an external email account and without having to set up a server of my own. Ideally I would not have to do anything but enter code into ruby command.

Is there any way to do this?

I couldn't find a clear step by step guide to using email on ruby, can someone point me in the right direction? Please assume that I know nothing. Thanks. I am not using ruby on rails. :-)

I have tried pony, but it would seem that I need an email to send the message from...? I would like to send the message directly from ruby.

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

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

发布评论

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

评论(1

囚我心虐我身 2024-12-03 15:04:45

这取决于。以下是一些技巧:

  • 返回地址不必是有效的,您可以虚构一个。但您难道不希望返回地址至少是您控制下的真实地址吗?
  • 执行此操作的原始、官方 IETF 方法涉及在 DNS 中查找目的地的 MX 或 A 记录,然后通过端口 25 上的 TCP 流通过 SMTP 将邮件发送到该主机。有一些 gem 可以执行此操作。
  • 在服务器上,上述方法可以工作,但话又说回来,服务器应该运行自己的带有队列和重试等的邮件中继,因此对上述技术的改进是跳过 DNS 并将消息发布到 localhost:25。
  • 但是,如果它是一个服务器,您不需要使用 SMTP,只需 5 或 10 行代码即可 popen() CLI 邮件代理之一,这些代理是:sendmail、mailx 或 mail。您现在可以使用 puts() 编写消息。
  • 如果它不是服务器(家庭电缆或DSL)或其虚拟服务器(EC2),那么直接邮件传输可能会受到某种限制。如果您在云中某处使用您选择的端口号操作自己的中继,则可以绕过这些限制。
  • 如果您发送的邮件数量超出黑名单或您的云提供商批准的数量,那么纯粹的技术解决方案可能还不够。解决这个问题的方法是使用第三方邮件递送服务。他们的工作之一是对黑名单实体进行社会工程并维持业务。

It depends. Here are some techniques:

  • The return address does not have to be valid, you can make one up. But wouldn't you want the return address to at least be a real one under your control?
  • The original, official, IETF way to do this involved looking up the MX or A record for your destination in DNS and then sending the mail via SMTP to that host via A TCP stream on port 25. There are gems that will do this.
  • On a server, the above works, but then again, a server should be running its own mail relay with queues and retry and such and so an improvement on the above technique is to just skip the DNS and post the message to localhost:25.
  • But if it's a server you don't need to speak SMTP, it's just 5 or 10 lines of code to popen() one of the CLI mail agents, which are: sendmail, mailx, or mail. You can just write your message with puts() now.
  • If it's not a server (home cable or DSL) or its a virtual server (EC2) then there may be some sort of restrictions on direct mail transmissions. If you operate your own relay somewhere in the cloud on a port number you choose you can get around these restrictions.
  • A purely technical solution may not be enough if you send more mail than a blacklist or your cloud provider approves of. The solution to that is to engage a third-party mail delivery service. One of their jobs is to social-engineer the blacklist entities and stay in business.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文