JavaMail Read Messages - java

Ok, so two questions. I'm able to access and read my new email inbox using javamail but:
If i try to read the messages already found by javamail, javamail seems not to be able to read them again.
Javamail cant read messages with numbers in the subject.
How can I make it so that both of these are possible?
Thank you
UPDATE:
Fixed question 1, I was using gmail and the setting needs to be configured so that the messages can be seen by JavaMail once opened. Still stuck on the second question though :(

You should be more specific with your question. You are using a POP3 provider? an IMAP one?
I use javamail and have processed millions of real world mails many of which certainly contain numbers in the subject, so I suspect it's not a javamail problem.
If you think so, add more data and stack traces etc

Related

Retrieve email from Postfix using Java

I'm trying to find an example on how to implement a Java client (using javamail perhaps) that retrieves emails from postfix, but unfortunately I haven't found anything usable in 8 hours.
I already managed to make an smtp client to send email to my postfix server running on localhost but still no success on getting that mail I sent back. With the imap client I always get some problems with the store and get connection refused.
Any suggestion?
Did you find the JavaMail FAQ? There's lots of tips there, including tips on how to debug and what additional information we would need to see to help you figure out what's wrong. So far all you've told us is that something's not working. Without more details, we can't offer more than general suggestions.

Flag SEEN not working with Yahoo! Mail?

I am using the JavaMail API to fetch mails. Earlier today I succeeded in doing so with Gmail. Now I tried Yahoo Mail and it worked too.
One problem though:
It doesn't show if the mail has been read or not correctly. I have a mailbox full of mails that have been read, though the application says I haven't.
I use this to determine if a mail that is fetched, have been read or not:
String isRead = (message[i].getFlags().contains(Flags.Flag.SEEN) ? "Yes" : "No");
It works with Gmail. Just not with Yahoo Mail.
Anyone got any idea why this might be?
What protocols are you using? I know Gmail supports IMAP so I assume that is what you are using there. Does Yahoo? If they only support POP3 then the flags won't work because POP3 doesn't support flags.
Try seeing what Folder.getPermanentFlags() returns.
Uh, Yahoo mail is broken?
If you set the flag, does it stay set?
You believe the message have been read by looking at the web mail interface, right? Does setting the flag change anything in the web mail interface?

Java: JavaMail, POP3 and few problems

I'd like to ask few questions about handling POP3 protocol with JavaMail (I'm building small web mail client):
How do I know which mail is new? Mail server doesn't provide this info explicitely. I have to iterate thru all mails and check with my database, which are new
What if someone sends a really big attachment? Is there way how not to download it and limit it to certain size? Like with MimePart?
POP offers only two reliable ways to keep track of which messages you've already downloaded. First is to delete them after downloading, which you evidently don't want to do. And second is to track UIDLs in your local database.
There is no way to download a subset of message parts via POP, as POP doesn't include a message structure model. You can fetch the first N lines from a message if the POP server supports the TOP command, but that probably isn't what you want.
It sounds like you want IMAP, not POP.

Java framework for sending emails

Do you know any framework in Java for reliably sending a huge amount of emails with the following features:
Send and receive emails
Concurrently process emails from a queue to maximize the throughput
Keep track of emails that could not be delivered
I know that writing my own is not very hard, but I was wondering whether there is already something sophisticated that I can reuse.
UPDATE: The use case for my question is not sending newsletters or spam. It's emergency mass notification, e.g. sending 50,000 emails within 5 minutes. I also do not want to implement my own mail server, I want to use existing mail server(s) with the JavaMail API. But the JavaMail API doesn't provide any facilities for queing and concurrently sending emails and keeping track of emails that could not be sent.
You use the Java Mail API to construct the actual messages you want to send, and let JavaMail use a production quality mail server to do the actual delivery.
An easy configuration to get up and running is postfix under Ubuntu Server.
Please, please, please do not send out unsolicited spam.
Send and receive emails? Perhaps you are looking for mailing list manager in Java? Take a look at Subetha which is successfully used in several production sites (and written in Java). http://code.google.com/p/subetha/
They have a sub module, called Subethasmtp, which you can use as a smtp server (in Java).
Try the Java Mail API. But for really bulk mailing you probably want to talk directly to SMTP.
You can use "JavaMail" or "GreenMail" for sending and receiving email

How can I recieive confirmation for delivered email with JavaMail API?

I'm writing a program, that sends email messages and want to know when the receiver receives the email message I've sent to him. How can I do this using JavaMail API?
If I use SMTPMessage, how exactly to deal with the result after I've set the notify options?
SMTPMessage smtpMsg = new SMTPMessage(msg);
smtpMsg.setNotifyOptions(SMTPMessage.NOTIFY_SUCCESS);
There is no standard way of doing this that's accepted and honored across the board. I see that you have some options, though:
Add a header "Return-Receipt-To" with your e-mail address in the value. If the recipient of the e-mail has a client which honors this header, then a return receipt will be sent to you when the e-mail is opened. This is not reliable, mind you, as the user can always decide not to send the receipt, even if he has a client that supports it.
Add an image into your e-mail that loads from your server and put a parameter on the image that includes the user's e-mail address. When the e-mail loads, the image will load from your server. Write a script that collects the e-mail parameter and then delivers a blank image. This is also not reliable, however, as many mail clients prompt users if they wish to download images and they can always choose not to. Also, some (mostly older) e-mail clients do not support images.
Perhaps the most reliable way is not to include the message in your e-mail at all. Include only a link to a website where the message can be read, and include their e-mail address or a unique code in the link. This way, you know exactly who read the message. Of course, this has the downside that people aren't actually getting the message in their inbox, and they also may choose not to go to the website to read it.
Ultimately, I think you're going to have to come up with a creative solution to solve this problem, unless you're happy getting spotty results.
Ok, this is an old discussion, but:
I've found a simple and working solution here (link in spanish).
You just need to add one more field to the header of the message. To achieve this you must use method addHeader of Part class, implemented by Message class. This method receives 2 parameters, type and value of header.
To get confirmation you must add this header:
Disposition-Notification-To
And the value is the mail where we want to send the confirmation answer:
message.addHeader("Disposition-Notification-To","mail#example.com");
ATTENTION: be aware that, nowadays, a lot of mail servers like gmail are discarding this requests, so this will not have effect, but, if you are sure (like me) receiver server allows this, will work like a charm.
please see my answer here (when this questioned was asked about ruby on rails). Tis basically the same answer.
Email open notification - ruby on rails
There is another approach to finding out whether an email has been received or not, it's getting undelivered emails. I've seen a rather good Java implementation here.
They used javax.mail (for mail processing) and guava (for processing strings and collections).
Just add a dummy image with display set to none in your message.And set the src attribute of this image to the url you want to call
You can use SMTP message and request for a delivery status (I don't know if it's coming when the provider receive the mail or if it's when the user open the mail).
JavaMail don't support directly these feature directly and you have to read the RFC 3464.
I also find this thread with examples but didn't try it javamail
You can also look at websina

Categories

Resources