AnsweredAssumed Answered

Mail Task

Question asked by amani on Apr 1, 2014
Hi, I have a problem with send Mail Task, I don't received anything. I use Apache James and JavaMail.
I put this code in listener of MailTask:
public class MailTaskNotification implements TaskListener{

private static final long serialVersionUID = 1L;

private static String HOST = "";
private static String USER = "";
private static String PASSWORD = "******";
private static String PORT = "465";
private static String FROM = "";
private static String TO = "";

private static String STARTTLS = "true";
private static String AUTH = "true";
private static String DEBUG = "true";
private static String SOCKET_FACTORY = "";
private static String SUBJECT = "Testing JavaMail API";
private static String TEXT = "This is a test message from my java application. Just ignore it";

public void notify(DelegateTask task) {
System.out.println("Enter in Email Task");   
//Use Properties object to set environment properties
Properties props = new Properties();

props.put("", HOST);
props.put("mail.smtp.port", PORT);
props.put("mail.smtp.user", USER);

props.put("mail.smtp.auth", AUTH);
props.put("mail.smtp.starttls.enable", STARTTLS);
props.put("mail.smtp.debug", DEBUG);

props.put("mail.smtp.socketFactory.port", PORT);
props.put("mail.smtp.socketFactory.class", SOCKET_FACTORY);
props.put("mail.smtp.socketFactory.fallback", "false");

try {

//Obtain the default mail session
Session session = Session.getDefaultInstance(props, null);

//Construct the mail message
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(FROM));
message.addRecipient(RecipientType.TO, new InternetAddress(TO));

//Use Transport to deliver the message
Transport transport = session.getTransport("smtp");
transport.connect(HOST, USER, PASSWORD);
transport.sendMessage(message, message.getAllRecipients());

} catch (Exception e) {
System.out.println("Mail sent successfully!");