Is there any java library to access client's emails? - java

I am looking for a java library to access(show) client's emails in a web app.
For instance user comes to the site, enters credentials, smtp and all this stuff (like when doing Import in Thunderbird or Outlook) and our website can show him his emails in the browser...
Are you aware of such library? Is this possible?
IIRC, JavaMail is mostly for sending emails but what I need is to access and list client's emails.

there many opensource client mail tools which can be coustomised as you need, please check below below
Client Emails Access
Update :
check this Chilkat
Here is a sample code how-to-create-an-e-mail-client-in-java

Yes Javamail can do exactly what you are asking. Javamail isn't for just sending emails. You can access a user's mailbox. Sending emails is over the SMTP protocol. Javamail supports SMTP, POP3, and IMAP. You're interested in POP3 or IMAP.
http://www.oracle.com/technetwork/java/javamail/index.html

Related

I need to send emails from an email hosted on a Microsoft Exchange server

I successfully created a java program that can send emails from a gmail account, however, now I need to do the same with an email account using a Microsoft Exchange Server.
The difference is when I was creating the gmail application I had all the information I needed to just plug into the JavaMail API program to make it work. For example, the SMTP server is smtp.gmail.com, the port is 587, the account needs to be set to "Less secure login requirements", etc...
I do not have access to any of this information for the Exchange Server. I am wondering if this is possible to do? I would assume I probably wont be able to use the JavaMail API like I did with gmail seeing as i don't have any of the information that is required for the fields. Is there some other library out there that I can use?
If some of this sounds like I don't really know what I'm talking about it's probably because I don't. This is kind of new territory for me, and I seem to have hit a wall. Basically I just need a program that can send an email from an account hosted on a Microsoft Exchange server. Hopefully this make since. Thanks.
Ms Exchange and GMail are both email providers, they rely on the same protocol : SMTP. So your JavaMail API should also work with Exchange, provided the required features are enabled :
SMTP : should be enabled by default, unless your admin disabled it.
SMTP Authentication, or SMTP relay for your sender IP address : Some authentication mechanisms (AUTH LOGIN) are disabled by default on latest versions of Exchange. Relay also has to be configured by the admin.
The easiest way to find out your exchange server address and port is to contact your Exchange administrator. However, you can find it by yourself by :
If you're not on the exchange local network, you can try "nslookup -q=mx senderdomain.com" to find out the Exchange IP adderss
Else, you can try and follow this procedure
Once you have the Exchange IP address, confirm that SMTP delivery port (25) is opened, it should be. If relay is authorized for your IP, you should be done.
Else, test if SMTP submission port (587) is opened, that should be the one you use to send authenticated emails.
Alternatively, you can try and use Exchange Web Services API, provided it's enabled on the server. There seems to be a Microsoft JAVA libray to use EWS : ews-java-api.

Is Mail server required for sending email?

I am not sure do i need to configure some mail server (like james) to send email from java api
like explained at this Java email send code example
No but its not a good idea.
When you want to use javax.mail session you need a mail server which accepts smtp connection from your app. This is preffered why.
But you could also write a socket based adapter which directly tries to deliver the mail to the receivers mail server by connecting by smtp and handle the protocol your self. That is theoreticaly, because most email server would not accept your application, because there spam protection will block you.
So my advice is. Don't think to much about this. Use a locale mailserver like james or one of the millions smtps proxies out there for development. And later in production change configuration to a well setup mailserver (most called MTA) where you can be sure that your mails will be delivered.
You do not need to set up one yourself. Mail providers, such as GMail and Outlook for instance, expose their own mail servers which you can use to transmit email messages.
Note however that in such cases, email transmission might eventually be blocked so as to discourage the delivery of SPAM mail.
yes :)
in this example it is installed at localhost, so mail is passed to another service within the same box. of course, you can use an external server, too - for example if you have a development system home, than utilize the mail server of your ISP.

How to send an email to a java program

I'd like to write a program, probably a servlet or something to run on the a google app engine that I can send an email to. So not a program to send email, but one that can receieve it and parse it.
My question is, what code or API are out there that can receive an email?
Basically on your google app engine you can use an inbound mail service.
Please see this documentation for more information.
http://code.google.com/appengine/docs/java/mail/overview.html#Receiving_Mail_in_Java
You cant send an email to a program, you send an email to a server, so what you are looking for is a way to access an email server via your program. Unfortunately there is no single solution here, you need to configure your program for every different email account/server you want to access. (If you have ever set up an account in outlook or something like it you will get the idea)
For example here is a link to the gmail api, you could use this to access gmail accounts
http://code.google.com/apis/gmail/
You need to have a mailbox to send message there and you could read messages with the code like this: http://www.java2s.com/Code/Java/Network-Protocol/GetEmailMessageExample.htm
This can be done with a built in Java library.
javax.mail
Check out this link. It should be able to help you get started.
This won't work for every mail server, but depending on your setup it might help.
To send an email to a Java program, that program must be running. Generally that means a server style (aka service) receiver is favored.
For the email to be received, the Java service must understand an email protocol. There are a number of protocols, but SMTP is the standard for receiving email. Once you have a service that understands SMTP protocol for receiving email, you have written a mail server.
Note that most people don't care to write a mail server, as a mail client needs to connect to the server and pull the email to make it readable. Keep this in mind when designing the solution to your problem.

How to put email to my own mailbox with Java mail API

I am trying to send simple text mail to myself from a servlet using Java Mail API. I wonder how to best approach this in order to avoid daily sent limits meant to restrict sending mail to other people.
How does a mail server receive email? From what information I could find, it is through the SMTP protocol? When the receiver happens to be local, instead of a relay the SMTP server assumes the role of local mail delivery agent. Is that correct? Any problems I could bump into when I connect directly to my SMTP server?
To avoid any confusion, I want my servlet to act as an SMTP server, NOT a mail client that connects to one. I want to make a mail server to RECEIVE a message going to my mail box, not relay one to other people.
Yes, SMTP is the protocol that a client uses to send an email message to a remote server.
Depending on the server software, there may be ways to send a message to a local server without using SMTP, but (as far as I know) the Java mail framework doesn't know about any of those, it can only use SMTP. So if there are limits on how much you can send, you'll just have to fix those limits directly.
If you want to test sending mail from your java application, and you have no development server to connect to, then install a local email server (hmailserver for windows, postfix for *nix).
Configure your email server to only receive email from localhost, and to only deliver to local clients (that way you wont spam the world with your test emails).
Once your happy with your application, you can point it at a production email server. How you connect and the amount of emails you can send will depend on your provider. If you are hosting your own email server you should get professional advice (or do a lot of reasearch) to prevent becoming a spammer, or having a spammer abuse your service (google for open relay).
The postfix site has plenty of good documentation and hmail server has a very good gui.

Integration of an email server in a Java EE application

I am building a web application that has to be able to do the following:
Send emails to the (external) addresses registered by the users (say, Gmail, Yahoo Mail, etc).
Send/receive emails to local mailboxes that live in the application. These are more "messages" in that sense.
What are the potential open source technologies I could integrate with here? Thanks for your inputs.
So, you want a SMTP server? If you want to have it in Java, then I can suggest to pick Apache James. But in fact every decent SMTP server would suffice. You can just use JavaMail API, or the more convenienced Apache Commons Email which is built on top of JavaMail API, to talk with any SMTP server to send/read emails.
If you didn't already realize, you can also just make use of an existing SMTP server provided by your ISP or the web hosting. In this case only JavaMail or Commons Email would have been sufficient.
While Commons Email will help you get the sending part done, receiving email will require that you access mailboxes via IMAP or POP through the Java Mail API.
Java Mail is a little cumbersome to use, but this Stackoverflow question has a working IMAP sample to help you get started.
There is a JCA (Java Connector Architecture) adapter that makes your Java EE server open port 25 for receiving mails.
http://sourceforge.net/projects/mailra/
A quite old tutorial which is incomplete with some examples for IMAP watching can be found here:
https://community.jboss.org/wiki/InboundJavaMail
A general introduction to JCA can be found here:
http://www.adam-bien.com/roller/abien/entry/a_simple_transactional_file_jca

Categories

Resources