getting drafts and sent items in Java using pop3 - java

I am facing a problem regarding getting the drafts and sent mail folder programmaticaly in Java. Although I am able to get the inbox using pop3 and able to send mail via smtp, I am not able to get it done by pop3. Thanks in advance for your reply.

The POP3 Protocol doesn't support folders at all, so the only one you can get is the INBOX.
All the other folders are stored locally within each POP3 client, so if you are writing one, you are free to do that in whatever way you like.
There might be POP3 servers that allow use of folders through extensions, but in that case they are not following the standard protocol and you will most likely implement something own or try to find some package specific for that mailserver.
If you want to use server-side folders in a standardized way, I suggest you look at IMAP. Most mail-providers do support both POP3 and IMAP and it supports storing folders on the server (including Drafts, Sent mail, and other customized folders).

When I look at this I would say that the standard POP3 protocol implementation provided with JavaMail does not support this.

POP3 does not supports the notion of differents folder. If the mail server supports IMAP then you'd be able to access all folders. The IMAP support in JavaMail is decent and easy to use.

Related

Java application to access MAILBOX using MAPI

I am trying to establish a connection between my mail server and a java program to parse the mail using protocol MAPI.. now the connection is working fine with a mock mailbox using IMAPS..but my mail server does not support MAPI..So is thr any option like JMAPI..
It seems like Java Supports POP3 and IMAP very well out of the box.
But for other protocols you can use one of the vendors found at JavaMail API - Third Party Products.
I've had problems communicating with the Novell Groupwise Protocol, luckily they have a IMAP bridge I could have used instead.
The Moonrug Exchange Connector looks like the one you are looking for, but you will have to purchase.
OpenMAPI looks like a promising one, but it is still in development.

Accessing email in a transparent fashion

How could one go about accessing email without interfering in any way that would be visible to a user with standard email clients such as Thunderbird?
P.S: I've marked this as both java and language-agnostic so the approach can be described in general steps or detailled programatically.
You would like to access the mail server directly over network programmatically. You only need to know the address (URL) of the mail server (usually in flavor of smtp.domain.com), the port number (usually 25) and the login username and password (the one of the existing mail account at the mail server).
In low-level, you need to know socket programming. In Java, there's the java.net.Socket API for this. Also see this tutorial. To communicate with a mail server you need to learn the SMTP or IMAP protocols, depending on what the mail server in question understands, to send/retrieve commands as bytes over the socket accordingly.
In high-level, you can use a more convenient API which doesn't require you to understand the low level specifics (which may be pretty complicated and verbose). In Java, you can use the JavaMail API for this. It has an excellent FAQ with a lot of code examples.

Sending mail from a java app without using an external SMTP server

JavaMail requires that you specify an external SMTP server when sending mail. I want to have my java app send email directly without having to use an external SMTP server such as postfix or sendmail.
Can anyone recommend a library which provides this kind of functionality?
Ive done some googling and have come up with nothing.
It's not trivial to send mail yourself. To start with, you have to deal with DNS (MX records), queuing, connection management and maybe signing (DKIM). So you wouldn't find any light-weight library like JavaMail to do this.
Your best bet is JAMES,
http://james.apache.org/

Sending Email using Java

I want my Java application to send out emails to users. But I cant get a good solution.
Now, I got some on Google but they use a SMTP server which I dont have. I was wondering if setting up one on my Linux machine would be easy?
So, I am using mailx now to send out emails but it sends emails from root which is definately not good. Is there any way to send out emails from a proper email using java? like you can do in php and other languages?
Use commons-email to send email from java in a simple, straightforward way (see the docs).
You need an SMTP server always - even in "php and other languages", but perhaps you don't know you need it, because it is bundled in your LAMP package.
One solution is to use google as an SMTP server. Either via your account, or via google apps. Otherwise setting up an smtp server (postfix for example) linux appears trivial, but isn't - you have to take into consideration many things - see this post by Jeff Atwood.
So ultimately, I'd suggest using the options provided by google.
if you'r looking to host your own mail server, then apache james is a pretty good option.
or other solution could be using a third-party mailservers such as gmail or yahoo; and use the JavaMail API to send emails.
If you don't have an SMTP server, Asprin is a send-only SMTP server, which is a pretty good fit. It suffers from the same problem any do-it-yourself SMTP server will, in that it will look more like a Spam source, so using a proper SMTP server used for e-mail should be done if possible.

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