views:

281

answers:

4

Hi, many weeks ago recommended me for send emails, ActiveMQ. So i search information about this, but i don't understand totally how this works. Could someone explain me why i should use ActiveMQ for send emails ?

+2  A: 

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
oxbow_lakes
+1  A: 

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.

pjp
+5  A: 

@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.

tim_wonil
A: 

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.

vinaynag