Reading mails using JavaMail - jakarta-mail

This question is more about the behavior. I have been using both POP3 and IMAP to access mails in Gmail using JavaMail API. I noticed something and I wanted to clarify my doubts regarding the same.
I am currently retrieving unseen mails from my Inbox. There were a couple of unread mails and I retrieved them using POP3. I switched over to IMAP and read the same inbox and I was able to retrieve the same 2 mails.
I've been recently using JavaMail and I encountered this kind of behavior and I wanted to know if this is the expected behavior?

You read your mail, did not delete or change anything, so when you read it again it was still there and unchanged. That's all.

Related

Getting http 500 backend error when posting to Gmail API

I am using the Gmail API to put messages into a Google Apps email account. I use
the OAuth 2.0 authentication protocol with a service account. This is more or
less working fine. One of our customers has asked us to put messages
directly into a Google Vault. I don't see a Vault API, but I did find this
information related to the "insert" method (which is what we use to add
messages to a normal account):
parameter "deleted" (boolean): Mark the email as permanently deleted
(not TRASH) and only visible in Google Apps Vault to a Vault administrator.
Only used for Google Apps for Work accounts.
When I do this, some messages are accepted, but frequently I get http error
500 in response to the POST. The error text says "Backend Error". I thought
the pattern was that the first time the message was posted, it would work,
but the second time would generate the error. Therefore I was thinking it
was a duplicate check issue. However I now see some examples of messages
that fail immediately. The POST url looks like this:
https://www.googleapis.com/upload/gmail/v1/users/user#domain.com/messages?uploadType=multipart&internalDateSource=dateHeader&deleted=true&access_token=ABC...
As I mentioned, the same message to the same url (without deleted=true) will
always work. Any ideas what is causing the error?
Was just fighting this issue myself. Apparently the error has something to do if the message is compatible with the Google vault retention policies:
If I turn on a default policy of "Retain everything" then I've been able to get the messages to import correctly. HTH!
I'm using the import api method and the backendError seems to be related to filters/policies. For example we asked Google to reject messages with xls and macros and we get the error on mail with that kind of attachment

Sending threaded email from Google App Engine

I've got an app that's sending email from AppEngine, but each email looks like it's a unique message. Instead I want related emails to be threaded in my email client. Is there a specific header/format I need to use?
These emails are not necessarily in response to another email, so I don't have a Message-ID to plug into References. I've tried using a natural key in References and In-Reply-To to no avail.
I was able to thread a list of emails just by using the In-Reply-To header with your format <msg-identifier#host>.
Supposedly, msg-identifier is the identifier to the message you're replying to, but as you're not replying to any message but sending all of them out of thin air, creating a new ID and using it in all the emails you send will also do the trick.
I got this working by using both References and In-Reply-To with the format <identifier#systemname>. Maybe it'll work with less; I made several changes at once. If someone chimes in with that kind of detail I'll happily accept their answer instead of mine.

How to request read receipt with Google App Engine

I have a GAE application which sends out email to my domain users in a Google Apps for Business environment. I am using JavaMail as described in this article. Unfortunately I can't seem to find a way to ask for a read receipt. I looked at Message methods but nothing seems to suggest that it is possible. Thanks a lot.
If you're interested in knowing if a mail bounced, then use bounce notification https://developers.google.com/appengine/docs/java/mail/bounce
For read receipts:
As far as I'm aware, you need to roll your own read receipt functionality. For example: Include an image(with a unique url) in the mail you send out. When the recipient opens the mail, the image is retrieved and you can determine whether the mail has been read. This has it's downsides; if they don't have images enabled, then you won't receive the notification.
You need to set the appropriate headers on your message, as described in Message Disposition Notification - RFC 3798. Not all mailers will honor MDNs, so you might find the tracking pixel useful as well. But then some mailers won't display remote images, so in the end there's no guaranteed way of getting notified when a message is read.

Best way to maintain consistency while implementing a mail client

Sorry if it's not a question conforming to SO standards but I don't really know where else to ask for advice.
I'm implementing a mail client which downloads all mails and stores them locally. Any mail deleted locally should be reflected in the online inbox and vice versa. Also if the download of mail stops before all mails are downloaded, it should resume from the stopped mail next time.
Currently I'm using a combination of message id and message uid for this but I heard it's not a reliable method for this. Can you guys suggest me any other approach ?
You should use IMAP UIDs. RFC 4549 should help.

How can I read Yahoo! Mail using JavaMail?

Using JavaMail, I am able to read and download mails from Gmail, but it is not working for yahoomail.com. I've tried it in all the possible ways I know, but nothing is working. While searching, I learned that Yahoo Mail does not provide POP3 for free users, so I tried IMAP, but it is also not working.
there is a workaround for this, please see
http://www.khimhoe.net/2011/06/11/how-to-enable-pop3-in-the-new-yahoo-mail-updated-11june2011/
for No7. Use menu link Forwarding instead of POP Access

Resources