为什么我应该使用 ActiveMQ 发送电子邮件?

发布于 2024-08-01 16:09:29 字数 1432 浏览 4 评论 0原文

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

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

发布评论

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

评论(4

我很OK 2024-08-08 16:09:29

@oxbow_lakes 的答案可能适合您的情况,但还有另一种可能性。
也许该建议(使用 ActiveMQ)的原因是希望发送电子邮件的客户端应用程序可以通过 ActiveMQ 将发送电子邮件的任务委托给电子邮件服务应用程序。 我看到的好处是调用是异步的,因此即使有数百万封电子邮件要发送,客户端应用程序也不会阻塞,因为这可以由后台的电子邮件服务应用程序处理。

@oxbow_lakes's answer maybe correct for your situation, but there's another possibility.
Maybe the reason for that recommendation (to use ActiveMQ) was so that the client application that wants to send an email can delegate the task of sending an email to an email service application through ActiveMQ. The benefit I can see is that the call would be asynchronous, so the client application will not block even when there are millions of emails to send, since that can be taken care of by the email service application in the background.

海之角 2024-08-08 16:09:29

您可能应该看一下 JavaMail。

http://java.sun.com/products/javamail/FAQ.html

import javax.mail.*;
import javax.mail.internet.*;

import java.util.Properties;

public class SimpleMail {
    public static void main(String[] args) throws Exception{
      Properties props = new Properties();
      props.setProperty("mail.transport.protocol", "smtp");
      props.setProperty("mail.host", "mymail.server.org");
      props.setProperty("mail.user", "emailuser");
      props.setProperty("mail.password", "");

      Session mailSession = Session.getDefaultInstance(props, null);
      Transport transport = mailSession.getTransport();

      MimeMessage message = new MimeMessage(mailSession);
      message.setSubject("Testing javamail plain");
      message.setContent("This is a test", "text/plain");
      message.addRecipient(Message.RecipientType.TO,
           new InternetAddress("[email protected]"));

      transport.connect();
      transport.sendMessage(message,
          message.getRecipients(Message.RecipientType.TO));
      transport.close();
    }
}

我猜您可以使用 AMQ 来排队电子邮件以发送到 SMTP 端点。 Mule 框架可以用来做到这一点。

You probably should take a look at JavaMail.

http://java.sun.com/products/javamail/FAQ.html

import javax.mail.*;
import javax.mail.internet.*;

import java.util.Properties;

public class SimpleMail {
    public static void main(String[] args) throws Exception{
      Properties props = new Properties();
      props.setProperty("mail.transport.protocol", "smtp");
      props.setProperty("mail.host", "mymail.server.org");
      props.setProperty("mail.user", "emailuser");
      props.setProperty("mail.password", "");

      Session mailSession = Session.getDefaultInstance(props, null);
      Transport transport = mailSession.getTransport();

      MimeMessage message = new MimeMessage(mailSession);
      message.setSubject("Testing javamail plain");
      message.setContent("This is a test", "text/plain");
      message.addRecipient(Message.RecipientType.TO,
           new InternetAddress("[email protected]"));

      transport.connect();
      transport.sendMessage(message,
          message.getRecipients(Message.RecipientType.TO));
      transport.close();
    }
}

I guess you could use AMQ for queuing up email messages to send to an SMTP end point. The Mule framework can be used to do this.

南冥有猫 2024-08-08 16:09:29

我认为沟通出现了故障。 ActiveMQ 是一个“消息传递”系统 - 这与电子邮件无关! 消息传递系统(AMQ 基于 AMQp 消息传递协议构建)是关于可靠的数据通信并解决以下问题:

  • 发布/订阅
  • 点对点
  • 保证交付

I think there has been a communication breakdown. ActiveMQ is a "messaging" system - this has nothing to do with emails! A messaging system (AMQ is built on the AMQp messaging protocol) is about the reliable communication of data and addresses issues such as:

  • Publish / subscribe
  • Point-to-point
  • Guaranteed delivery
好菇凉咱不稀罕他 2024-08-08 16:09:29

Active MQ 与发送电子邮件无关。 Active MQ 用于通过网络发送消息。 当您发送电子邮件时,您所需要的只是 smtp 主机服务器详细信息。

Active MQ has nothing to do with sending e-mails. Active MQ is used for sending messages over the network. While for you to send the e-mails, all you need is the smtp host server details.

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