• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in sending email  RSS feed

 
Imran Mirza
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you behind a proxy? Is 80.227.102.42 available on your LAN?
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does the server accept connections from the domain you're trying to send from?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the "Other Java APIs" forum, since the question is only about JavaMail, and doesn't really have anything to do with JSPs.
 
Imran Mirza
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, we are behind the proxy.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well JavaMail won't work from behind most proxies, since they are usually configured only to relay HTTP, not SMTP. Read the JavaMail FAQs.
 
Imran Mirza
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, but its running fine locally even we are behind proxy.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!