• 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

JavaMail API

 
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
I have a little problem because of my "greeness" in JavaMAil API. What is the my Server host? I mean how can I obtain such an information? I believe it's quite stupid question, but.... Thanks in advance...
 
Marshal
Posts: 28177
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 asking what is the name of your e-mail server?

If it's the e-mail server for the company you work for, find the administrator and ask them. Yes, really. Just ask.

If it's a web server like Gmail, then there should be some documentation on how to connect to the server using mail programs. For example if you configured Microsoft Outlook to connect to your web mail, you will already have put the name of your e-mail server into its configuration somewhere.

If this doesn't help, then post again with more details about your specific situation.
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I just newbie in Java Mail. I started reading Sun's online training about this topic, and stuck with and exercise of creating simple mail sending... I just do not know what is my SMTP Server. How can I find out this, or maybe you can redirect me at some source where I would find this and further explanation.
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alternatively, if it is for own convenience only, then you need to install a mail server yourself. For example Apache James.
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you. could you maybe reference me to some written source (book, documentation...) about JavaMAil Api?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The http://faq.javaranch.com/java/JavaEnterpriseEditionFaq page points to a number of good resources regarding JavaMail, particularly an extensive tutorial on java.sun.com that has many code examples.
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok. Well I've started on sun-s tutorial, but as I mentioned above, this is my first encounter to JavaMAil, so I find it a little bit not understandable (Hahh, I stried to create a simpel mail application, just to send a "Hello", but I do not know the host for sending. Can you give me a glimpse on this host-issue?). thanks...
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To send and retrieve mails, you need a mail (SMTP) server.
To interact with a mail server using Java, you use the JavaMail API.

JavaMail is not a mail server and it look like that you thought that it was somehow.
At least, JavaMail itself already provides an excellent FAQ: http://java.sun.com/products/javamail/FAQ.html

If you don't want to install and run a mailserver at your own PC using for example Apache James (or others), then you can also use the mailserver of for example your own ISP, or your company or webbased others like Gmail. But you need to consult their documentation or support team to get the connection details, such as the SMTP host name, port number and so on which you can use in your JavaMail configuration settings.

Edit: I see in your topic history that you are less or more familiar with JSP/Servlet.
You can compare JSP/Servlet API less or more with JavaMail API.
With JSP/Servlet (and HTML) you can use HTTP to transfer data between client (webbrowser) and server (Tomcat or so).
With JavaMail you can use SMTP to transfer data between client (mailprogram) and server (James or so).

Do you got it now?
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you have, that was I need - an outline of mailing - . Thanks a lot.
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One more thing. It seams to me that I, let say, need to have a two servers simultaneously to work, in orde to provide some web application which use JavaMail. I guess that is not pretty good solution. Does J2EE oriented containers have this ability to support both purpose (purpose of Tomcat and James) ?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, James is a Java application, so if you dig into its code it should be easy to find its main class, and embed that into your web application (maybe start it in a ServletContextListener). Thus you'd have only a single server.

But the drawback is that if you need to take down one of the servers for any reason (or it goes down on its own), then the other will be down, too.
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So what is solution - to embed those part of James code into our web application, or some containers in production, already have this feature integrated within?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I didn't want to have a second server running, I'd probably embed James into a separate web app. That way at least I could start/stop both applications independently of each other.
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok thanks. Only what I need to do is to integrate James into code (sound pretty easy :-))) hehehe, I could imagine ) For now I wanted just an outlined to be informed about JavaMail and so on.. I believe in a month I'll start grainer study about this topic. Thanks once again of valuable references!
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, a while ago here we were discussed about JavMail. It's considered that I need James server to perform mail sending. I'm now going on j2ee AS, and I found that there is embedded JavaMail API. Is it only API embedded with libraries (so I do not need to download JavaMail API's, and set jar's into classpath), or there is also and James aembedded, or I still need to integrate James in my application?
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It does not include James, so you will need to download and integrate that separately.
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi. I have a problem during mail sending. I use mu ISP smtp. I can read mail from my code (read from my inbox of my ISP), but I cannot perform mail sending. This is the code for sending :



When I try to read messages from ISP my , I use my pop3.gromnet.netprovider, and messages from ISP (sent and received) were being retrieved. However, when I try to send message, this is the message I get :


So, where do I wrong???
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There doesn't seem to be any authentication code; how are you trying to set the password?
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Of course but I'm newbie in JavaMail. I've just figure out googling that this part of code is necessary :


Could you advice me, refer me, to potential obstacles I'll probably face in JavaMail API? I know this is some general question, but just to prepare me for some inevitable exceptions/errors which may occurs in this API? I'm gonna study it just to understand the base, so I could implement James in my application... Thanks everyone on support..
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The best advice I can give is to work through the tutorial I mentioned earlier. It covers all the basics, and quite a bit more. You might also check out the other JavaMail links on that FAQ page.
 
Rob Spoor
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error message seems to indicate that the ISP's mail server does not allow the relaying. Can you send messages from that address from a "regular" email client such as Outlook (Express) or Thunderbird?
 
Paul Clapham
Marshal
Posts: 28177
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

Rob Prime wrote:The error message seems to indicate that the ISP's mail server does not allow the relaying.



Well, of course. Any responsible ISP wouldn't allow its SMTP server to be used to send messages claiming to be from a Gmail account which it knows nothing about. For that to work, the "from" address would have to be an address in the ISP's own domain, which appears to be "gromnet.net". And even then the ISP still might require authentication.
 
Rob Spoor
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not necessarily. My ISP (and my previous one too) allows me to send emails from my own domain which the ISP knows nothing about, and probably would allow GMail, HotMail and the likes. They simply check if I'm connected to their network, if I am I can use their mail server with virtually any email address. At present I use my ISP's mail address, 4 accounts of my own domain and another account, and all allow sending from them through the same ISP.

Of course this doesn't mean that all ISPs work like that, that's why I suggested the test with Outlook (Express) or Thunderbird. If that has the same problem then the ISP is definitely the issue.
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, as I said, it was about authentication issue, and I solve it. And yeas, I could sent an email using outlook, but I didn't perform authentication process in my code, which I should (the ISP explicitly denote that authentication is required, which also I must perform in my outlook express). When I refine my code, everything is just fine. But there is another thing:
How can I get all messages from my ISP mailbox? I can retrieve by code, only the messages stored in the INBOX folder, no matter if use 'pop3' or 'imap' (but I found out that pop3 only can manipulate with INBOX folder. So hoe can I access set folder? I use 'imap' provider and try to specify


and get an exception :


However, I've looked at my webmail place on my ISP and find that folder for sent messages are named - 'INBOX Sent'. So I try to rename :


and I get:


So, how can I approach to other folders?
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi. I have a problem when I want to retrieve a disposition of message.
Previously I created a message, add attachment to is, and invoke :
The message successfully goes into my INBOX. But when I try to retrieve a messages attributes like in this code

It appears that message.getDisposition() returns null. Why is that???
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Slobodan,
please start new topics for questions that are unrelated to the original problem. It gets hard to follow what's going on if the subjects veers all over the place.
 
reply
    Bookmark Topic Watch Topic
  • New Topic