0

Possible Duplicate:
Could not connect to SMTP host: email-smtp.us-east-1.amazonaws.com, port: 465, response: -1

My application shows this error when I try to send mail through Lotus Domino server using JavaMail API with my company's mail ID:

javax.mail.MessagingException: Could not connect to SMTP host: mail.tranzlease.com, port: 465, response: -1

I am able to send the mail through my Gmail ID.

public void sendtoGroup(String sub,String msg) {
  try {
    String host = "mail.myweb.com";
    String from = "vinod.patil@myweb.com";
    String pass = "12345";
    Properties props = System.getProperties();
    props.put("mail.smtp.starttls.enable", "false"); // added this line
    props.put("mail.smtp.host", host);
    props.put("mail.smtp.user", from);
    props.put("mail.smtp.password", pass);
    props.put("mail.smtp.port", "465");
    props.put("mail.smtp.auth", "true");

    String[] to = {"vinod.patil@myweb.com","vinodpatil76@rediffmail.com"}; 
    Session session = Session.getDefaultInstance(props, null);
    MimeMessage message = new MimeMessage(session);
    message.setFrom(new InternetAddress(from));

    InternetAddress[] toAddress = new InternetAddress[to.length];

    // To get the array of addresses
    for( int i=0; i < to.length; i++ ) { // changed from a while loop
        toAddress[i] = new InternetAddress(to[i]);
    }
    System.out.println(Message.RecipientType.TO);

    for( int i=0; i < toAddress.length; i++) { 
        message.addRecipient(Message.RecipientType.TO, toAddress[i]);
    }
    message.setSubject(sub);
    message.setText(msg);
    Transport transport = session.getTransport("smtp");
    transport.connect(host, from, pass);
    transport.sendMessage(message, message.getAllRecipients());
    transport.close();
  } catch(Exception e) {
    e.printStackTrace();
    }
  }
}
Community
  • 1
  • 1
win98
  • 586
  • 1
  • 6
  • 10

1 Answers1

0

This is not the standard SMTP mail port (port 25). I think port 465 is for SMTP+SSL.

Make sure your admins have enabled "smtp over ssl" on the Domino server.

Jeroen Jacobs
  • 1,423
  • 3
  • 16
  • 32