This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JavaMail Connections  RSS feed

 
Karthik Vijayarajan
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
This is my first shot at the JavaMail API. As i understand, one can register the host details in JNDI and can access the same to send emails. I am thinking of the Mail Service Providers as Driver Softwares that know Mail Protocols and have the required knowledge to connect to a Mail Server. I guess i can see an analogy between this and JDBC/LDAP connections. I understand that we may pool JDBC/LDAP Connections. My questions are...

1)When we get a Mail Session from the JNDI, are we creating a connection to the mail server? Or, is this any different from the JDBC/LDAP Connections?

2)Is it possible to pool connections to the Mail Server? (Does it even make sense? )

I browsed thru couple of books and also looked at internet. I didnt find anything so far that says "Pool Mail connections".

Thanks for your help.

Thanks
Karthik
 
Joe Ess
Bartender
Posts: 9425
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by karthik vijayarajan:

1)When we get a Mail Session from the JNDI, are we creating a connection to the mail server? Or, is this any different from the JDBC/LDAP Connections?


I don't think so. If you look at the Session API doc the Session object seems more about settings than connectivity:
It collects together properties and defaults used by the mail API's. A single default session can be shared by multiple applications on the desktop. Unshared sessions can also be created.

I believe it is some subclass of Transport provided by your mail implementation that actually does the work of connecting to the server.

Originally posted by karthik vijayarajan:

2)Is it possible to pool connections to the Mail Server? (Does it even make sense? )

I'd say yes, but it would cost more than it is worth.
The reason we pool database connections is because they are non-trivial to create and they are designed to be long-lived, with the client and server exchanging large amounts of information with detailed security and resource management. SMTP, on the other hand, has little overhead.
If it were smart to pool SMTP connections, there'd probably be a class in the API like DataSource.
 
Karthik Vijayarajan
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your thoughts.
Your inputs were very helpful. I guess i could have done better with the API . I missed the Transport class.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!