Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-09-2009, 10:28 AM
Member
 
Join Date: Jul 2009
Posts: 18
Rep Power: 0
satheeshtech is on a distinguished road
Default email delivery status verification
Hi all,
im using javamail api to send mail.. when i send mail if i give non-exixtence email address,
i hav to get error message ..
any suggestion pls
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 07-09-2009, 11:45 AM
RamyaSivakanth's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Chennai
Posts: 533
Rep Power: 1
RamyaSivakanth is on a distinguished road
Default
hi Sateesh,
Gothru this api and send method below
Transport (Java 2 Platform Ent. Ed. v1.4))

send
public static void send(Message msg)
throws MessagingExceptionSend a message. The message will be sent to all recipient addresses specified in the message (as returned from the Message method getAllRecipients), using message transports appropriate to each address. The send method calls the saveChanges method on the message before sending it.
If any of the recipient addresses is detected to be invalid by the Transport during message submission, a SendFailedException is thrown. Clients can get more detail about the failure by examining the exception. Whether or not the message is still sent succesfully to any valid addresses depends on the Transport implementation. See SendFailedException for more details. Note also that success does not imply that the message was delivered to the ultimate recipient, as failures may occur in later stages of delivery. Once a Transport accepts a message for delivery to a recipient, failures that occur later should be reported to the user via another mechanism, such as returning the undeliverable message.



Parameters:
msg - the message to send
Throws:
SendFailedException - if the message could not be sent to some or any of the recipients.
MessagingException
See Also:
Message.saveChanges(), Message.getAllRecipients(), send(Message, Address[]), SendFailedException

__________________
Ramya
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-09-2009, 01:06 PM
Member
 
Join Date: Jul 2009
Posts: 18
Rep Power: 0
satheeshtech is on a distinguished road
Default
Hi Ramya,
thanks but i hav already tried SendFailedException and MessagingException class.. actually this exception is not thrown even though i give some non-exitence recipient address..
code wat i tried is

// create a message
Message msg = new MimeMessage(session);

// set the from and to address
StringBuilder smtpFrom = new StringBuilder();
String from = map.get("partnerName") == null? "" : (String)map.get("partnerName");
if (! from.equals("")) {
smtpFrom.append(from).append(" ");
}
smtpFrom.append("<");
smtpFrom.append(MailUtils.getSmtpFrom()).append("> ");
log.info("Sent mailer");
log.info(smtpFrom.toString());
log.info("Sent mailer");
msg.setFrom(new InternetAddress(smtpFrom.toString()));

final String sendReportTo = (String) map.get("sendReportTo");
msg.setRecipients(Message.RecipientType.TO,
getInternetAddressArrayFromStringOfAddress(sendRep ortTo));

final String cc = (String) map.get("cc");
if (!"".equals(cc.trim())) {
msg.setRecipients(Message.RecipientType.CC,
getInternetAddressArrayFromStringOfAddress(cc));
}

final String bcc = (String) map.get("bcc");
if (!"".equals(bcc.trim())) {
msg.setRecipients(Message.RecipientType.BCC,
getInternetAddressArrayFromStringOfAddress(bcc));
}

final String subject = (String) map.get("subject");
// msg.setHeader("Subject", subject);
msg.setSubject(subject);
final String key = (String) map.get("key");

msg.setHeader("Message-ID",key);

//msg.setHeader("References",key);
Multipart multipart = new MimeMultipart();


//
// Set the email message text.
//
final String content = (String) map.get("content");
MimeBodyPart messagePart = new MimeBodyPart();


// messagePart.setText(content);
messagePart.setContent(content,"text/html; charset=UTF-8");
multipart.addBodyPart(messagePart);

//
// Set the email attachment files
//
if(map.get("bodyParts")!=null){
List<MimeBodyPart> bodyParts = (List<MimeBodyPart>) map.get("bodyParts");

for (MimeBodyPart mimeBodyPart : bodyParts) {
multipart.addBodyPart(mimeBodyPart);
//multipart.getBodyPart(index)
}
}
// add the Multipart to the message
msg.setContent(multipart);
log.info(" ** before transport");
//msg.addHeader("key", arg1)
try { Transport.send(msg);
} catch(SendFailedException sendFailedException) {
log.info(" ** ValidUnsent Addresses");
Address[] validUnsent =
sendFailedException.getValidUnsentAddresses();

if (validUnsent != null) {
log.info(" ** ValidUnsent Addresses");
if (validUnsent != null) {
for (int i = 0;
i < validUnsent.length; i++)
log.info(" "+validUnsent[i]);
}
}

}

Enumeration<Header> enumSent=msg.getAllHeaders();
while(enumSent.hasMoreElements()){
Header h = (Header) enumSent.nextElement();
if(h.getName().equalsIgnoreCase("Message-ID")){
sentKey=h.getValue();
}
}



} catch (MessagingException e) {
log.info(e.getMessage());
log.error("Cann't send report via e-mail: some errors", e);
}
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-09-2009, 01:07 PM
Senior Member
 
Join Date: Apr 2009
Posts: 792
Rep Power: 1
Tolls is on a distinguished road
Default
Originally Posted by satheeshtech View Post
Hi all,
im using javamail api to send mail.. when i send mail if i give non-exixtence email address,
i hav to get error message ..
any suggestion pls
If you expect to get an error message for the "user" (whether a real user, or a program somewhere) when they send the email, that won't happen.

You cannot determine the existence of an email address (so long as the email address is in a valid format).
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 07-09-2009, 01:42 PM
Member
 
Join Date: Jul 2009
Posts: 18
Rep Power: 0
satheeshtech is on a distinguished road
Default
Hi Tolls,
ok we cannot determine the existence of an email address.. but is there any way to determine undeliverd emails
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 07-09-2009, 01:57 PM
Senior Member
 
Join Date: Apr 2009
Posts: 792
Rep Power: 1
Tolls is on a distinguished road
Default
Originally Posted by satheeshtech View Post
Hi Tolls,
ok we cannot determine the existence of an email address.. but is there any way to determine undeliverd emails
Trawl throught your inbox the following day looking for bounced back emails?
It can take hours for an email to bounce back as undeliverable.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Verification peiceonly Java Servlet 2 04-04-2009 08:38 AM
username password verification bheezee Database 0 11-25-2008 07:55 PM
send email using apache commons email jnamendi JavaServer Faces 0 10-14-2008 06:55 PM
Input Verification Dialog Demo Java Tip javax.swing 0 06-26-2008 08:43 PM
Input Verification Demo Java Tip javax.swing 0 06-26-2008 08:42 PM


All times are GMT +2. The time now is 06:05 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org