Results 1 to 6 of 6
  1. #1
    satheeshtech is offline Member
    Join Date
    Jul 2009
    Posts
    18
    Rep Power
    0

    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

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    798
    Rep Power
    6

    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:cool:

  3. #3
    satheeshtech is offline Member
    Join Date
    Jul 2009
    Posts
    18
    Rep Power
    0

    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);
    }

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default

    Quote 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).

  5. #5
    satheeshtech is offline Member
    Join Date
    Jul 2009
    Posts
    18
    Rep Power
    0

    Default

    Hi Tolls,
    ok we cannot determine the existence of an email address.. but is there any way to determine undeliverd emails

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default

    Quote 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.

Similar Threads

  1. Image Verification
    By peiceonly in forum Java Servlet
    Replies: 2
    Last Post: 04-04-2009, 07:38 AM
  2. username password verification
    By bheezee in forum JDBC
    Replies: 0
    Last Post: 11-25-2008, 06:55 PM
  3. send email using apache commons email
    By jnamendi in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 10-14-2008, 05:55 PM
  4. Input Verification Dialog Demo
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-26-2008, 07:43 PM
  5. Input Verification Demo
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-26-2008, 07:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •