Cannot catch invalid email addresses

Hi,
I have been using this very normal email sending routine but for some reason even if the email address is invalid (ex abc), the Transport.send() method does not throw any exception and continues.
Does anyone know why this should happen??
The code is given below
     for (int i = 0; i < p.length; i++){
uEmail = p.getUserEmail();
System.out.println("Sending Email to :" + uEmail);
     emailContent = emailString;
/***************** SENDING THE EMAILS *************************/
try {
          Properties props = System.getProperties();
//System.out.println("Using mail server"+mailserveraddress);
          props.put("mail.smtp.host",mailserveraddress);
          Session session = Session.getDefaultInstance(props, null);
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("[email protected]"));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(uEmail));
message.setSubject("Homeland Headlines " + dateString);
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText(emailContent);
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
//System.out.println("Setting the content");
message.setContent(multipart);
          //System.out.println("NO exception till here");
// Send the message
Transport.send(message);
          System.out.println("Email Sent successfully");
catch(SendFailedException me) {
          System.out.println("Email not sent to :" + uEmail);
          System.out.println("The exception is" +me.toString());
          invalidemails.add(uEmail);
          catch(MessagingException mesex){
          System.out.println("The exception is:"+mesex.toString());
          sentemailflag="false";
          catch(Exception e){
               System.out.println("Unexpected error is:"+ e.toString());
               sentemailflag="false";
The control never reaches any of the exception blocks even though p has some invalid email addresses.
It prints:
Sending email to: abc
Email sent successfully
Thanks,
Chetan

Hi,
I believe I have answered this question quite a few times in this forum.
There is no standard way to know if the e-mail id exists or not, SMTP standards does not mandate the server implementors to notify this.
There are several things that can happen:
a. The server implements the VRFY command -- Then you know immediately if the account is active.
b. The server does not implement the VRFY command, but if the acount does not exist tells you when you send the RCPT command.
c. The server does not tell you till you say QUIT.
d. The server accepts the mail silently and sends a mail later saying that the mailbox does not exist.
Since there is no sure-shot way of determining this no exception is thrown.
(Also check out the RFC for a typical SMTP session if the commands confuse you.)
cheers
Projyal

Similar Messages

  • How to catch invalid emails & How to send to multiple emails

    This is a long two-part question.
    Part One:
    I would like to catch invalid emails within the JavaMail code and send the valid emails. I am using the following code to do this. The problem I am running into is when there is a valid email, sometimes it will be caught within the code without being sent and it will show up as a validunsentemail. I have set sendpartial to true, so this shouldn't be happening. Also, is there a way to check if a domain name is in existence before sending the email?
    Part Two:
    For testing purposes, I would like to mix valid and invalid emails for TO, but I don't know how to send to more than one email using an array. I have looked at other posting on the forum of how to do this, but I keep getting errors when I try other's suggestions. Maybe somebody will be able to help with this problem if they see the code below.
    Thanks in advance for all your help!
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    import javax.mail.event.*;
    import javax.activation.*;
    public class Practice
    public static void main (String[] args) {
    Transport trans = null;
    try {
    Properties props = System.getProperties();
    props.put("mail.smtp.host", "hostname");
    props.put("mail.smtp.sendpartial","true");
    Session mailConnection = Session.getDefaultInstance(props, null);
    Message msg = new MimeMessage(mailConnection);
    Address angela= new InternetAddress("[email protected]");
    InternetAddress[] address ={new InternetAddress("[email protected]")};
    msg.setRecipients(Message.RecipientType.TO, address);
    msg.setContent("This is a test. This is only a test. What's Next?", "text/plain");
    msg.setFrom(angela);
    msg.setSubject("Testing 123");
    msg.setSentDate(new Date());
    msg.saveChanges();
    trans = mailConnection.getTransport(address[0]);
    trans.connect();
    trans.send(msg, address);
    System.out.println("Mail was sent successfully.");
    try {Thread.sleep(5);}catch(InterruptedException e){}
    } catch (MessagingException mex){
    try {Thread.sleep(5);}catch(InterruptedException e){}
    mex.printStackTrace();
    System.out.println();
    Exception ex = mex;
    do{
    if (ex instanceof SendFailedException){
    SendFailedException sfex = (SendFailedException) ex;
    Address[] invalid = sfex.getInvalidAddresses();
    if (invalid != null){
    System.out.println(" ** Invalid Addresses");
    if (invalid != null) {
    for (int i=0; i< invalid.length; i++)
    System.out.println(" " + invalid);
    Address[] validUnsent = sfex.getValidUnsentAddresses();
    if (validUnsent != null){
    System.out.println(" ** ValidUnsent Addresses");
    if (validUnsent !=null){
    for (int i=0; i<validUnsent.length; i++)
    System.out.println(" "+validUnsent[i]);
    Address[] validSent = sfex.getValidSentAddresses();
    if (validSent != null){
    System.out.println(" **ValidSent Addresses");
    if (validSent != null){
    for (int i=0; i<validSent.length; i++)
    System.out.println(" "+validSent[i]);
    System.out.println();
    if (ex instanceof MessagingException)
    ex = ((MessagingException)ex).getNextException();
    else
    ex = null;
    } while (ex != null);
    } finally {
    try {
    trans.close();
    } catch (MessagingException mex){  /*  ignore */}

    I am working on exactly the same problem. What you need to do is use the destination mail server to send mails. For example: address
    [email protected] is an invalid user.
    Using normal way you wont be able to catch invalid mail box error.
    If you use mail server of jabcreative.com to send email then you will get an unknown user exception.
    To find mail server of jabcreative.com you will have to do MX LookUp on DNS entry
    Have a look at this URL
    http://www.cee.hw.ac.uk/courses/5nn2/3/12.htm

  • Highlight an invalid email address in a custom workflow activity in SharePoint Designer 2010

    Hi,
    I have created a custom workflow activity to send an email with the 'From' address being taken as input from the SharePoint Designer when this activity is used in a designer workflow. My requirement is to highlight an invalid email address(from address)
    on click of 'Check for Errors' button in SharePoint Designer like it is done for mandatory inputs by default where it highlights such inputs if left blank. Is it possible?
    Thanks in advance.

    Good work, catch so far Michael, does seem to be a "feature" of iCloud syncing, not sure what you could do to disable it.

  • Blackberry ID Associated to Invalid Email Address

    Hello,
    I've made a awful mistake of adding a blackberryID to my phone with an invalid email address.
    I can't change it as I can't remember what password I set.
    I can't recover the password, as it's an invalid email address.
    Is there anything I ca do to get this sorted (I have since created a blackberry ID to the correct email address).
    Thanks
    Rob Cross

    Hi and Welcome to the Community!
    Given your situation, only human intervention can help you now. The automated processes simply cannot deal with such a situation. To receive that, you must ring up your mobile service provider and convince them to escalate your case up to BlackBerry. Further, you must convince BlackBerry to provide you with a solution -- which likely will either be resetting your current BB ID so that you can again access it or having you create a new BBID and they will manually move your purchase records over. Note that I have no idea if they will be willing to do this, but there is no other way that I know of to retain your prior AppWorld purchase records.
    But, first please decide if such is even necessary. If, for example, you did nothing with that other BB ID (e.g., no AppWorld purchases, no BBM contacts, etc.), then you can simply abandon it and use the new one you have created.
    Good luck!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • I have forgotten my password for icloud, have an invalid email address and do not know my security answers. How can I transfer all my data from my old iphone to the new one?

    I have forgotten my password for icloud, have an invalid email address and do not know my security answers. How can I transfer all my data from my old iphone to the new one?

    In this case you won't be able to do that?

  • I changed my Apple ID that using an invalid email address to a new one and I am trying to update iCloud account on iPhone5 with iOS 7.1.2, and I am not able to delete iCloud account without the old password.

    I changed my Apple ID that using an invalid email address and I am trying to update iCloud account with my new Apple ID on iPhone 5 with iOS 7.1.2. I am not able to delete iCloud account without the old password. Is there a way to update the Apple ID of my iCloud account?

    Many people are having probalems with this right now.  The only solution I've seen that seems to consistently work is the one posted by Brackers28 here: https://discussions.apple.com/message/23020591#23020591.  This only works if you still have access to your old email account.  If you don't, you'll have to have Apple help you reset the password for your old account so you can turn off Find My iPhone and sign into your account with your correct ID.

  • Exchange 2007 in iCal not working. - Invalid Email address

    I did the exchange setup - Email works.
    Addess book - Contacts are there but the Global Address book does not produce anything.
    iCal - all the setting are correct but it won't connect to the calendar. The error:
    Invalid Email address. It is the correct address and works in the other areas.
    Any ideas????
    Seems like other have issue as well
    Thanks
    Paul
    Our Exchange service is provided by Intermedia.
    Are there detailed instructions for the Exchange settings

    I'm having the same problem here. Gerr.

  • How to delete an apple-id that was created with an invalid email address?

    After upgrading to IOS.5.0, my apple-id for the IPod was incorrectly change to an invalid email address.
    I have verified my apple id on itunes on my desk top. How ever, the apple id on the IPad  is still an invalid address which I can't validate or change.
    Any ideas will be appreciated.
    Thanks
    Mitch

    If everything works in iTunes on the computer see if this works. Sign out of the invalid account/email address and the sign in with the correct one on the iPad. Settings>Store>Apple ID - sign out.
    Restart the iPad before you try signing in with the correct ID.
    Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.

  • What are valid and invalid email address characters

    What are valid and invalid email address characters in Exchange 2010, for example can you have Conan.O'[email protected] is there a document that shows the valid and invalid sysmbols?

    Hi
        The format of email addresses is
    local-part@domain where the local-part may be up to 64 characters long and the
    domain name may have a
    maximum of 253 characters - but the maximum 256 characters length of a forward or reverse path restricts the entire email address to be no more than 254 characters.<sup id="cite_ref-0">[1]</sup>
    The formal definitions are in RFC 5322 (sections 3.2.3
    and 3.4.1) and RFC 5321 - with a more readable form given in
    the informational RFC 3696<sup id="cite_ref-1">[2]</sup>
    and the associated errata.
    Local part
    The local-part of the email address may use any of these
    ASCII characters
    RFC 5322 Section
    3.2.3:
    Uppercase and lowercase English letters (a–z, A–Z) (ASCII: 65-90, 97-122)
    Digits
    0 to
    9 (ASCII: 48-57)
    Characters
    !#$%&'*+-/=?^_`{|}~ (ASCII: 33, 35-39, 42, 43, 45, 47, 61, 63, 94-96, 123-126)
    Character
    . (dot, period, full stop) (ASCII: 46) provided that it is not the first or last character, and
    provided also that it does not appear two or more times consecutively (e.g. [email protected] is not allowed.).
    Special characters are allowed with restrictions. They are:
    o   
    Space and
    "(),:;<>@[\] (ASCII: 32, 34, 40, 41, 44, 58, 59, 60, 62, 64, 91-93)
    The restrictions for special characters are that they must only be used when contained between quotation marks, and that 3 of them (The
    space, backslash \ and
    quotation mark " (ASCII: 32, 92, 34)) must also be preceded by a backslash
    \ (e.g.
    A quoted string may exist as a dot separated entity within the local-part, or it may exist when the outermost quotes are the outermost characters of the local-part
    (e.g. abc."defghi"[email protected] or
    "abcdefghixyz"@example.com are allowed. Conversely,
    abc"defghi"[email protected] is not; neither is
    abc\"def\"[email protected]). Quoted strings and characters however, are not commonly used.
    RFC 5321 also
    warns that "a host that expects to receive mail SHOULD avoid defining mailboxes where the Local-part requires (or uses) the Quoted-string form".
    The local-part "postmaster" is treated specially - it is case-insensitive, and should be forwarded to the server's administrator. Technically all other local-parts
    are case sensitive, therefore [email protected] and [email protected] specify different mailboxes. However most organizations treat uppercase and lowercase letters as equivalent, and also do not allow use of the technically valid characters
    (space, ? and ^). Organizations are free to restrict the forms of their own email addresses as desired, e.g.,
    Windows Live Hotmail,
    for example, only allows creation of email addresses using alphanumerics, dot (.), underscore (_)
    and hyphen (-).<sup id="cite_ref-2">[3]</sup>
    Systems that send mail must be capable of handling outgoing mail for all valid addresses. Contrary to the relevant standards, some defective systems treat certain
    legitimate addresses as invalid and fail to handle mail to these addresses. Hotmail, for example, refuses to send mail to any address containing any of the following standards-permissible characters:
    !#$%*/?^`{|}~
    Domain part
    The domain name part of an email address has to conform to strict guidelines: it must match the requirements for a
    hostname,
    consisting of letters, digits, hyphens and dots. In addition, the domain part may be an
    IP address
    literal, surrounded by square braces, such as jsmith@[192.168.2.1], although this is rarely seen except
    in email spam.
    Examples
    Valid email addresses
    <tt>[email protected]</tt>
    <tt>[email protected]</tt>
    <tt>[email protected]</tt>
    <tt>much."more\ unusual"@example.com</tt>
    <tt>very.unusual."@"[email protected]</tt>
    <tt>very."(),:;<>[]".VERY."very@\\\ \"very"[email protected]</tt>
    Invalid email addresses
    <tt>Abc.example.com</tt> (an @ character must separate the local and domain parts)
    <tt>[email protected]</tt> (character dot(.) is last in local part)
    <tt>[email protected]</tt> (character dot(.) is double)
    <tt>A@b@[email protected]</tt> (only one @ is allowed outside quotation marks)
    <tt>a"b(c)d,e:f;g<h>i[j\k][email protected]</tt> (none of the special characters in this local part
    is allowed outside quotation marks)
    <tt>just"not"[email protected]</tt> (quoted strings must be dot separated, or the only element making
    up the local-part)
    <tt>this is"not\[email protected]</tt> (spaces, quotes, and backslashes may only exist when within
    quoted strings and preceded by a slash)
    <tt>this\ still\"not\\[email protected]</tt> (even if escaped (preceded by a backslash), spaces, quotes,
    and backslashes must still be contained by quotes)
    Terence Yu
    TechNet Community Support

  • HT5620 I want to change the email address to which all the reset security information (emails) go to. But I cannot see that email address in the list when I click on the 'Name, ID and Email Addresses' section.

    I want to change the email address to which all the reset security information (emails) go to. But I cannot see that email address in the list when I click on the 'Name, ID and Email Addresses' section.
    How can I change it when I cannot view it on my account. I am not even sure how this got setup.

    If you mean your rescue email address, it's in the Passwords and Security section, after you answer the two security questions.

  • Invalid email address or password

    Hi,
    New to blackberry and have been setting my 9300 up today. I have my own dedicated server and a number of domains. I have three main domains and associated email addresses.
    I have setup 2 email addresses and they work fine but the third keeps giving me "invalid email address or password" when I try to set it up, the login credentials are correct and I can access the email from desktop and webmail, just not the blackberry.. I own the domains and the server they run on.
    The ones that work are:
    [email protected] 
    [email protected]
    the one that doesn't work is:
    [email protected]
    Not sure if the hyphen in the domain name or the .org.uk is causing the issue as they are all on the same server and the .co.uk and the .net work without issue?
    Thanks
    Michael

    Typing www.blackberry.com/integrate in your phone's browser has been known to resolve this issue. 
    Give it a try and report back with your results.  
    - If my response has helped you, please click "Options" beside my post and mark it as solved. Clicking the "thumbs up" icon near the bottom of my response would also be appreciated.

  • When trying to set up sync, why does it always tell me invalid email address?

    I've downloaded Sync, I registered and signed up for Firefox add-ons.
    When I try to set up Firefox Sync.. I type in my username, password, then when it comes to email address, whatever letter I type first a red/white X box comes up saying invalid email address. Why?

    telliot, your reply is a bit cryptic, but I finally understood what you meant. What he/she meant, folks, is to keep on typing what you know to be your valid email address. When you enter ".com" (or whatever extension) the error signal will disappear

  • When trying to set up Sync account and enter my actual password, I get an "invalid email address"warning. Help...

    When I go into Sync and try to set up an account, I am asked for email address (which is <[email protected]>. Immediately as I enter the "meinig58" the "invalid email address" red warning comes up. How do I solve this problem and establish my Sync account?

    Write the whole email address and wait for a second to validate it.
    The validator tells you that you have entered the wrong email until you finish typing a valid one. Developers are working to fix it.

  • Trying to set up a group email "RAM" that will contain multiple email addresses.  Receive error messages "check SMTP settings" or "Invalid email address" when I try to send a message to the group.

    I am trying to set up the group email "RAM" that will contain multiple email addresses.  I have inputted the name "RAM" as a corporation.  In the section labeled "Email" I have inputed multiple email addreses so that when I want to send an email to the group "RAM" I just have to input the name "RAM" in the section labeled "To" , input the Subject in the Subject box & the email will be sent to the multiple addresses, yet when I do I receive either one of two error messages being "Invalid Email Address" or "Check SMTP settings" each of which allows me the option of with cancelling the email or send it anyway.

    Bump. I'd like to know, too. I even have some synched Groups from my Apple Address Book I email to using Apple Mail on the Powerbook, but I can't see how to do a group mailing on the Touch either.
    In normal Mail, I just start typing the name of the group, and it autocompletes, I hit return, and it fills in all addresses in the Group.

  • My printer gave me my email adddress, but when i try to sign in it says invalid email address

    invalid email address when i try to sign in

    Are you trying to use the email address on the print out? That is your ePrint printer code. When you go to http://www.eprintcenter.com you will want to create an account and after you create your account, it will ask for the printer code to customize your ePrint email address.
    If you are trying to create an account and it is saying invalid email or email already in use, it means that you have a snapfish account. In that situation, you will want to go to http://www.snapfish.com/ and click the login button in the top right hand corner of the page. When it prompts you to enter your email address and password, click the "Forgot your password?" link and enter your email address. They will send you a email with a temporary password and a link to change the password. After you change the password, go back to http://www.eprintcenter.com/ and log in with your email address and the password you just created.
    -------------How do I give Kudos? | How do I mark a post as Solved? --------------------------------------------------------

Maybe you are looking for

  • Unable to center webpage in browser window!!!

    Hi! I have looked for and tried almost everything to center my webpage in the browser window yet it doesn't work! this is the page: www.claudechalhoub.com. I want the page to be centered regardless of the browser window size! I have included the foll

  • Thread-safe alternative to XmlValue

    Hi, I'm using bdb xml in an application which visualizes 3d data stored in xml. When I load the data, it will be written into the db and I#m using XPath as query language. This works quite good, but as I'm using multiple threads within my application

  • Windows Server 2008 X64 - gpupdate takes 10min - svchost.exe (gpsvc) pid logs 8.5 million events in procmon

    Hello, We've seen that on our 2008 x64 servers the svchost.exe that holds gpsvc in it takes up alot of CPU-time. Upon further investigation I saw that when it refreshes policies it holds 1 core for 10 minutes. I setup a procmon and filtered it on the

  • Im due for an upgrade next month.....

    In your guys and gals opinions, should I get the 4S or should I tough it out and wait for 5 (when I have not clue when it is being released). My 3GS is really slowing down now, I have had it for 2.5 years....... I can't decide..... what does everyone

  • Oracle Form Services Installation (Test.fmx) Trigger Not working

    Hi I install oracle BI and forms Services on oracle application infrastructure after installation i run the following command "http://ora.server.com:7778/forms/frmservlet?config=testfrm" it will show the form "form services install sucessfully" but w