How I can track an email?
I' m using java on the server side for sending emails. I want to track whether it is delivered , opened, etc... How I can do that ?
This is not a Java specific issue.
You can create an HTML email, and embed an invisible gif which will report back to your server. Some software like Outlook and some web mail programs will block this for untrusted emails.
You can request a return receipt. Many mail programs ignore this entirely, and the ones which don't usually ask the user if they want to send it.
Example:
email.AddHeaderField("Disposition-Notification-To","<g.revolution#stackoverflow.com>")
There is no way to ensure that you always get the delivery or open-message notification.
Mailservers may accept the mail and drop it afterwards.
users may read the mail but dismiss the notification.
"Webbugs" (aka images in the html source of the mail that include a special token that allows the mail to be recognized) don't work in most email programs.
As a matter of fact it's very unlikely that you can see that someone got the message.
What you could do is to keep the message on your server and only send a link. If the user clicks that you can be pretty sure that he got the message. But thankfully many users would not click on such links because it's used in fraud and spam.
I suppose you're sending it through SMTP. Whenever your mail is sent to your SMTP server, your java program has no control of it:
1) If you want to know if your mail has been delivered, you should contact your SMTP server somehow (if the SMTP server is outside your control then forget that) and see if your mail has been sent.
2) You can't know if a mail has been opened by its receiver. The maximum you can do is set a flag that the mail requires acknowledgement, but that depends if the user explicitly wants to send that acknowledgment. Other possibility is set some link to your site within the mail that should be clicked to see the content. You will be able to track if the user clicked that link.
what you can do is -
you have to embed an invisible image in the body in which the src will call the page in server and log that event, you can only do it in HTML encoding.
example -
<img src="ImageServer.aspx?imageID=track.jpg& custID=134ghxx34343ai& campID=32434"/>
and then in ImageServer.aspx there will a handling code which will log that event or save it to database.
example -
private void Page_Load(object sender, System.EventArgs e)
{
// content type should be resolved programmatically
Response.ContentType = "image/jpeg";
if (!IsPostBack) Track();
Response.WriteFile(GetImageFileByID());
}
In case you send HTML email, you could add a 1x1 pixel image with some tracking parameters, that calls back to your webserver. It's not 100% reliable since some email clients (and users) block images in emails.
You can add something like
<span style="display:none">Tracking no: ${TRACK_NO}</span>
to the body of the email. This should always be in the response unless the email client strips it out.
Related
I used javax.mail to get Emails. I'm able to fetch email details like attachments, cc, bcc, from, to, text, subject. The issue I'm facing is It is getting only that email not all the messages in that email. Let suppose A sent email to B and B replied back to A. Then again replied to B. Now if I'm login with A's profile and I fetch INBOX folder of A. I get this email and when I check message.content() of that email It shows only reply of B. I want to get content of first message and third message sent by A as both of the messages belong to this thread.
IIRC conversation threads are implementation dependent cause it's not enforced nor covered in the IMAP RFC. There are some servers like gmail that lets you configure those settings. In your case it might be possible to read a specific message and then performing other IMAP verbs to retrieve the rest of the thread.
More info: https://www.rfc-editor.org/rfc/rfc3501
How do I read the original subject of the kick back email received from the mail delivery system.
I am doing it this way: messageSubject = message.getSubject(); which actually returns the wrong one i.e ”Delivery status notification” (this one I can see under subject of view message details of kick back email).
It is normal for a "bounce" email that you get in response to an email that cannot be delivered to have a different subject to the email that you sent. The original email may be included as an attachment to the notification.
The responses that you get in this scenario are not standardized and vary from one mail server (MTA) to another. If you are going to process them automatically, you will need to understand the structure of the responses you are getting from your MTA and potentially the remote MTA that are bouncing the emails.
You should probably start by looking at the bounce emails in your email to get an idea of their structure.
Here is what I am trying to do:
Add a special button to attach files to Notes "New message" window. If files were attached using this button, when email sent, they should be uploaded to the server and link to them added to the email.
My question - is it possible (and how) to capture "send mail" event in the plugin for Lotus Notus?
I don't know how an Eclipse plugin would do this. Furthermore, since Notes can be used off-line -- when it would be impossible to upload files to a server -- it would be better to have code running on the Domino server intercept the mail messages and perform the upload.
Most products that hook mail operations on the server use the Lotus Notes C API's Extension Manager functions to hook the EM_BEFORE notification for the EM_NSFNOTEUPDATE event and check whether the NSFNoteUpdate operation occurred within the server's mail.box files, and then check whether the the message requires special processing (i.e., in your case that would be by looking for a special NotesItem that your button code has inserted into the message). The usual coding method for this is to immediately change the status of the message to put it on hold, preventing the Domino router from attempting to send the message while your code is still working on it. Many products actually have two components - the EM hook DLL and a separate server task that receives a signal from the hook DLL, processes the message, and then releases it from on hold status. This approach keeps your code from tying up router threads while processing large files.
(Note: Newer versions of the Domino server have the ability to use OSGI plugins written in Java instead of using the Notes C API for operations like this. I've not looked into the details of how this might work for operations that process mail messages. )
I sort of figured it out. There is a very nice extension point provided in 8.5 - "com.ibm.notes.mailsend.MailSendAttachmentsDialog", that is specifically exists for custom handling of attachments. You can see it in plugin.xml, in IBM\Lotus\Notes\framework\shared\eclipse\plugins\com.ibm.notes.mailsend_8.5.*.jar.
The only problem is - it handles just attachments and does not have access to anything else. So if somebody figured how to get subject line and the message text from there, please reply.
Update: got it.
NotesUIElement elem = (new NotesUIWorkspace()).getCurrentElement();
if (elem instanceof NotesUIDocument) {
NotesUIDocument doc = ((NotesUIDocument) elem);
String to = doc.getField("EnterSendTo").getText();
String cc = doc.getField("EnterCopyTo").getText();
String bcc = doc.getField("EnterBlindCopyTo").getText();
String subject = doc.getField("Subject").getText();
String body = doc.getField("Body").getText();
....
}
I tried to send emails with Amazon SES, with the Java AWS SDK, and it worked. I would like to be able to check (at a later time) whether the delivery was successful. I will define it successful if the final mailserver accepted the mail for delivery.
I saw that when you send an email you can get a messageId that uniquely identifies your email:
SendEmailRequest request = new SendEmailRequest(from, destination, message);
SendEmailResult result = service.sendEmail(request);
String messageId = result.getMessageId();
However I saw that you can get only aggregated statistics, for example with SendDataPoint (Represents sending statistics data. Each SendDataPoint contains statistics for a 15-minute period of sending activity).
I'm not using SES to send bulk emails, but personalized notifications on a very low volume and I'd be interested to check every single message.
Did I overlook something? Is it possible to do this type of check with SES?
Amazon does provide a mechanism for you to capture bounces, which provides you with contrapositive verification.
You can create a mailbox to receive bounce notifications, then tell SES to forward bounce notifications there. e.g.:
request.setReturnPath("bounces#example.com");
You can then write code to periodically check that mailbox, and parse the messages for the destination email address.
Amazon provides a brief explanation of how they handle bounces & complaints here:
http://aws.amazon.com/ses/faqs/#37
However, if you want to check if the message avoided the spam filter or was read by the end user, that is beyond the scope of SES (although they work hard to ensure deliverability).
We use Bouncely.com. You simply set the ReturnPath to bounces#bouncely.com and it tracks all the bounces and spam reports. It also has an API that allows us to unsubscribe users automatically.
Use Amazon Simple Notification Service and define an HTTP endpoint to receive notification in case of email bounces. Works perfectly.
I was trying to see if there was a way to search an email inbox from javax.mail. Say I wanted to send a query and have the it return emails to us. Can we parse returned HTML and extract data. Also, if the above is possible how would I "translate" those messages returned by that server to POP3 messages? E.g. we have extracted:
Subject: Foo
Body: Bar
but to open same message using POP3 I need to know it's POP3 uid, or number. I don't think we'll be able to get UID but perhaps we can figure out the number.
I guess the question is:
Can I send a query to email server (such as Hotmail or Yahoo) and get returned emails?
Unfortunately, the POP3 protocol doesn't support that. It is not like SQL or so. You need to mirror the complete mailbox yourself in some kind of a datastore (SQL database?) and execute the search on that. You can eventually keep/cache the data so that you don't need to retrieve the whole inbox everytime, but only the unread items.