open source mail clients in java - java

Are there any open source email clients in java that you can recommend?
Something that pulls in emails via pop, sends emails, stores sent emails, etc.
Similar to what mozilla thunderbird does, but on build using jsp etc. for the web.
(preferably web based, but would also be interested in desktop apps)

I can point you at Davmail, its not a java smtp server or a desktop client, but its an outlook gateway that implements itself as a smtp/pop3 server. So you can put Thunderbird on your desktop and use it (via davmail) to access Exchange.
Works really well, but the code is available if you want to see some smtp/pop3/emaily-type code.

Related

Is it possible to send mail using Java when gmail access is blocked

I have working code to send mail using gmail smtp. It's working on my machine, but when I'm trying to run same code from my office system, then it showing error Unable to Connect SMTP Server. So, I was wondering, is it possible to send mail by bye-passing local/office network ? Any work-around ?
PS: I can't use my corporate email address, since it's internal task.
What you need to do is install a mail server on your machine and use that mail server to send emails. There are a lot of opensource and/or free options available. I have used hMailServer in the past (on Windows7), and it seemed to work for me, just the way I wanted it to. One possible downside of using this approach is that your emails may sometimes end up in the spam folders of your intended recipients.
However, you will need Administrator privileges to install most mailservers.

How to let browser send messages to a local java application?

I want the browser to send a message to my local Java application (which is programmed by myself) when I click a button on a web page which is also written by myself using php. Is there any way I can do that?
This is the wrong way. You don't send information from your server to your local application. Your local application should grab the information from your web server.
The local Java application can implement a webserver. There is a number of libraries out there, or you can use ServerSocket / SSLServerSocket to implement it low level. The server socket should be bound to localhost in order to prevent direct external access.
You can use JSONP to communicate with this local webserver.
Pay special attention to authentication, because any website you visit, can instruct the browser to send requests to the local webserver.

Fastest way to get E-mail from Exchange Server for GWT application using IMAP or Exchange Web service?

I am trying to get emails from Microsoft Exchange server using EWSJ API which in terms uses Exchange Web Services; but I would like to know; will it be fast to fetch emails using IMAP?
Since we have GWT we cannot directly connect to Exchange from client side in either case; we want to minimize the turn around time of getting emails on server side and then passing those to client side using serialized POJOs.
Apache Hupa is a subproject of the Apache James project, and it is a webmail client developed with GWT, it uses a server side able to get messages from any IMAP enabled server (it uses the javax.mail api).
Although you can use directly Hupa to read and send emails using your email server (there is a properties file to define imap and smtp parameters), in your case you could get the server side to connect to your servers and use any GWT ajax mechanism to get the messages like Hupa client side does.
Here you have a live demo of Hupa.
From my experience IMAP seems to be the fastest at the moment. I used it once to create a small program that could fetch emails from GMail. A bonus is that you can mark emails as "read" from the IMAP interface.
If I had to choose I'd go for IMAP.

Building e-mail server

I have a project with a use case where users should be able to send private messages to other users but this should be integrated with their e-mail box. They should be able to send either private messages or e-mail messages from the same screen.
My thought is to use some kind of open-source e-mail server which will dump the e-mails into MongoDB and then have my Java API pull them out and display them on the interface. And when a user sends an e-mail it is passed by the API to the e-mail server.
Is this a reasonable approach?
If you want your own server (not unreasonable in many cases), check out Apache James - an open-source Java mail server with a plug-in capability. Obviously (!) you can use JavaMail to talk to this, pull messages back etc.
Doesn't Gmail do all of this already? If you want email with chat integration,* that's the first solution that comes to mind. Why reinvent the wheel?
*and about a bajillion other awesome features

What is needed to add emailing capabilities to web application?

I have java web application to which I'd like to add emailing capabilities, however, I'm unsure what is needed to accomplish this. Specifically I want my app to be able to:
Send emails confirming sign-up
Allow users to send emails to one another, using my app's domain i.e. dan#my-app.com
From my research it seems I'll need a mail transfer agent (MTA) like Postfix and possibly a IMAP server like Courier; but I don't understand the need for the IMAP server.
Thanks.
You need code inside your web app to create and dispatch the email into the SMTP-world. Usually JavaMail is used for this, and you can either enclose it in your web application or (preferred) have the web container provide a correctly configured instance through JNDI. This is vendor specific.
If you do not have a SMTP-server for JavaMail to connect to (frequently this is Exchange for Windows shops), you can either get one running (ask your IT administrator) or use Google Mail or Hotmail or others if it is ok for your web application to send mail through them. It is a bit tricky to use GMail as a SMTP-server, but when set up correctly works very well.
You will need the SMTP-server, as it handles all the boring details regarding MX records and resending if the SMTP-server does graylisting, etc. etc.
Oh, and IMAP is for getting delivered mail, not sending mail. You don't need it.
If it's a Java web app, then the server part is a servlet. Given an email message sent from a client form, your server needs to send that text off as an email.
There's code in the Java EE stack to do this, or you can specifically download JavaMail. This will allow your programs to act as mail clients.
Your MTA receives messages from your servlet and sends them to the users. So far so good.
But you also need a postbox, i.e. the equivalent of a mail in-box for your users. Postfix, QMail and others offer a basic "flat" mailbox model, where mail is simply stored until the client picks it up, and then (usually) deleted. Access is via POP3. IMAP offers a lot more organizational capability, i.e. the ability to specify hierarchies of nested mailboxes, to transfer mails between them and so on. You probably won't want to create a GUI front end to all that complexity, so I'd guess you don't really need an IMAP server. You do, however, want a relatively simple POP3 server to allow your servlet to access the mailboxes via TCP/IP. This is usually part of the "standard" email server packages.
To have your own domain known to the world, you need access to the MX records of your DNS service, i.e. you have to set up one or two of your hosts, on an Internet-facing address, to be your post office.
Finally, if you want to save yourself a lot of trouble, be very careful in configuring your MTA (SMTP server) such that there is no chance for it being used as an open relay. i.e. it should not be possible for your users to send mail to the outside world in general (or hackers will find a way to abuse your Web interface to do this), and mail from the Internet should not reach your users. Most importantly, there should be no way for mail from the Internet to be forwarded to someplace else in the Internet. Find an open relay testing service (they're free) on the 'net and get one to run a test on your configuration once you think you're done.
EDIT:
Looking at Thorbjorn's answer, I realized you probably don't want your users receiving their mail through your app; they probably already have email providers and accounts of their own. In that case, you don't need to worry about inbox capability or a POP3 server. You could consider offering full email services at your domain but that's a very thankless job and if you have any choice, leave that dirty work to GMail, Yahoo, Hotmail and their ilk. Whatever service you provide will never please your customers enough, and you'll be fighting spam and other crime every day.
For starters your server has to have mailing abilities. In linux land sendmail is usually what this will be.
Additionally, check out javaMail.
http://www.oracle.com/technetwork/java/index-jsp-139225.html

Categories

Resources