posted 19 years ago
When i am sending email locally from the LAN, its working fine.
but when i upload it to static IP server it gave me following error:-
Sending failed; nested exception is: javax.mail.MessagingException: Could not connect to SMTP host: 80.227.102.42, port: 25; nested exception is: java.net.SocketException: Software caused connection abort: connect
Following is my code i am using to send email:
Properties props = new Properties();
props.put("mail.smtp.host", smpt);
// create some properties and get the default Session
Session session = Session.getDefaultInstance(props, null);
//session.setDebug(true);
// create a message
Message msg = new MimeMessage(session);
// set the from and to address
InternetAddress addressFrom = new InternetAddress(txtFrom);
msg.setFrom(addressFrom);
msg.setRecipient(Message.RecipientType.TO, new InternetAddress(txtTo));
// Optional : You can also set your custom headers in the Email if you Want
// Setting the Subject and Content Type
msg.setSubject(txtSubject);
// start Imran
msg.setSentDate(new Date());
// end Mirza
msg.setContent(txtMessage, "text/html");
Transport.send(msg);
Thanks in advance.
regards, Imran