• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unable to send an email from java

 
Ranch Hand
Posts: 153
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am writing a program to send an email from java but i'm unable to send it i'm getting an error. the code and details are as below.


while executing this i get the below error.

  • Exception in thread "main" java.lang.RuntimeException: javax.mail.SendFailedException: Sending failed;
    nested exception is:
    javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587;
    nested exception is:
    java.net.ConnectException: Connection timed out: connect
    at mail_j.PlainTextEmailSender.main(PlainTextEmailSender.java:39)
    Caused by: javax.mail.SendFailedException: Sending failed;
    nested exception is:
    javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587;
    nested exception is:
    java.net.ConnectException: Connection timed out: connect
    at javax.mail.Transport.send0(Transport.java:219)
    at javax.mail.Transport.send(Transport.java:81)
    at mail_j.PlainTextEmailSender.main(PlainTextEmailSender.java:34)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 42 seconds)


  • i'm getting the same error even if i use port number 587 and 25
    Thanks
     
    Marshal
    Posts: 28193
    95
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    The error message says that the code can't connect to that remote computer. Usually that is because there is no physical connection between the two computers, or else because there is a firewall or proxy or some other component which blocks the connection.

    So check your network connectivity.
     
    Rakesh Keerthi
    Ranch Hand
    Posts: 153
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks for your reply Paul.
    yes my office uses a proxy for internet conectivity. how do i solve this issue over there. i know what the proxy ip address is.

    Thanks
     
    Paul Clapham
    Marshal
    Posts: 28193
    95
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    You are doing this for work? Then your network manager should be able to help you get connected, assuming it's a work project. Although I'm a bit surprised your office doesn't have its own e-mail server which you could use.
     
    Rakesh Keerthi
    Ranch Hand
    Posts: 153
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Paul,

    my office uses MS exchange server.

    Thanks
     
    Rancher
    Posts: 43081
    77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    So he can give you all the information you need.
     
    Ranch Hand
    Posts: 530
    Hibernate Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Rakesh Keerthi,

    If you are using Gmail SMTP server, make sure you enable SMTP for your Gmail account settings.
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic