Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaMail newbie

 
Roel De Nijs
Sheriff
Posts: 10041
127
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like i said, i am a javamail newbie and i'm trying to get it to work, but i can use all the help possible.

To configure outlook express i use pop.xxx.be, smtp.xxx.be, username and password. My pc is behind a router. Can i use this code to send an e-mail


Is this correct code or do i have to do something else?

Thanks for all your time!
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks OK. Of course you will find out as soon as you try it.

A few general tips with JavaMail:
  • telnet to the SMTP server you are using - a nice quick test to see if your connection params are right.
  • enable SMTP debugging (see JavaMail docs). This saves so much pain if you can actually see the SMTP messages your code is generating.
  • Add Connection and Transport handlers. Another good debugging tool.
  • Refer to the JavaMail FAQs, which help a lot (lots of common mistakes in there, such as the ubiquitous "I can't connect to the server. I'm behind a proxy" problem.
  • Talk to the server admins who look after the SMTP server you want to use. Trying to connect to a resource when you have no visibility how it is maintained is just asking for trouble.


  • Good luck.
     
    Roel De Nijs
    Sheriff
    Posts: 10041
    127
    AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The code above doesn't give any error, but i don't get an e-mail.

    I tried "telnet smtp.xxx.be" but couldn't get a connection. I also tried "ping smtp.xxx.be" and that's working fine.

    Anyone any ideas?
    Thanks!
     
    Paul Sturrock
    Bartender
    Posts: 10336
    Eclipse IDE Hibernate Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    I tried "telnet smtp.xxx.be" but couldn't get a connection

    Is there a firewall between you and the smtp server? Are you behind a proxy?
     
    Roel De Nijs
    Sheriff
    Posts: 10041
    127
    AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Paul,

    Big celebration: post number 1000

    i turned my firewall of, so there isn't. There is a router and i think they use also a proxy.

    IS there some freeware where you can make a smtp-server on your own pc or something like that (for winXP)
     
    Paul Sturrock
    Bartender
    Posts: 10336
    Eclipse IDE Hibernate Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Yes - you can use James which is an open source SMTP server. Better though is Dumbster which is intended as a test harness for programming with SMTP, so you can test that at least your code is working before having to deal with all the infrastructure issues.

    Speaking of which, if there is a proxy between you and your SMTP server that could well be the problem, since proxy servers only tend to support HTTP. Check out the Java Mail FAQs for more detail.
     
    Roel De Nijs
    Sheriff
    Posts: 10041
    127
    AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    i downloaded the dumbster-project and i did run the AllTest

    This is my output:


    I changed the email-adresses into ones of my own, but don't get anything in mailbox. My server is localhost and everything goes well

    but when i change this server into smtp.xxx.be i get this error:


    so the port-number is already in use, but i tried it with a lot of different numbers, but always get this error

    how can i send an email to my own email ?
     
    Paul Sturrock
    Bartender
    Posts: 10336
    Eclipse IDE Hibernate Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The JVM_Bind stuff looks like it is happening because you are trying to run Dumbster while an instance is already running. Do you start it as part of your tests?
     
    Roel De Nijs
    Sheriff
    Posts: 10041
    127
    AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    i started it with server "localhost" and then i got no problem, but when i do change it in something else, this error is thrown and i have only one dumbster running at a time.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic