cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unable to send mail using java API , mail is from godaddy

 public class MailSender {

        private static String HOST = "smtpout.asia.secureserver.net";
        private static String PORT = "80";

        public static void sendMail(final Mail mail) throws MailException {

            EmailValidator validtor = new EmailValidator();

            if (validtor.validate(mail.getReceipient())) {
                Properties props = new Properties();
                props.put("mail.smtp.host", HOST);
                props.put("mail.smtp.socketFactory.port", PORT);           
                props.put("mail.smtp.auth", "true");
                props.put("mail.smtp.port", PORT);

                Session session = Session.getDefaultInstance(props,
                        new javax.mail.Authenticator() {
                            protected PasswordAuthentication getPasswordAuthentication() {
                                return new PasswordAuthentication(mail.getUsername(),mail.getPassword());
                            }
                        });

                try {
                    Message message = new MimeMessage(session);
                    message.setFrom(new InternetAddress(mail.getSender()));
                    message.setRecipients(Message.RecipientType.TO,
                            InternetAddress.parse(mail.getReceipient()));
                    message.setSubject(mail.getSubject());           
                    message.setText(mail.getBody());
                    Transport.send(message);
                    System.out.println("OK");

                } catch (MessagingException e) {
                    throw new MailException(e.getMessage());
                }           
            } else {
                throw new MailException("Email address not valid.");
            }       
        }
    }
javax.mail.MessagingException: Exception reading response;
nested exception is:
java.net.SocketException: Connection reset
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1764)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1523)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:453)
at javax.mail.Service.connect(Service.java:313)
at javax.mail.Service.connect(Service.java:172)
at javax.mail.Service.connect(Service.java:121)
at javax.mail.Transport.send0(Transport.java:190)
at javax.mail.Transport.send(Transport.java:120)
at poc.MailPOC.main(MailPOC.java:107)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at sun.security.ssl.InputRecord.readFully(Unknown Source)
at sun.security.ssl.InputRecord.read(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readDataRecord(Unknown Source)
at sun.security.ssl.AppInputStream.read(Unknown Source)
at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:106)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:84)
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1742)
... 8 more
EXCEPTION IN MAIL SENDER