File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other JSE/JEE APIs and the fly likes JavaMail newbie Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "JavaMail newbie" Watch "JavaMail newbie" New topic
Author

JavaMail newbie

Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5599
    
  15

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!


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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.


    JavaRanch FAQ HowToAskQuestionsOnJavaRanch
    Roel De Nijs
    Bartender

    Joined: Jul 19, 2004
    Posts: 5599
        
      15

    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

    Joined: Apr 14, 2004
    Posts: 10336


    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
    Bartender

    Joined: Jul 19, 2004
    Posts: 5599
        
      15

    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

    Joined: Apr 14, 2004
    Posts: 10336

    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
    Bartender

    Joined: Jul 19, 2004
    Posts: 5599
        
      15

    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

    Joined: Apr 14, 2004
    Posts: 10336

    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
    Bartender

    Joined: Jul 19, 2004
    Posts: 5599
        
      15

    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.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: JavaMail newbie