none
Valid email address being rejected by system.net.mail RRS feed

  • Question

  • Very frustrating situation.

    A valid email address is   a@booco.com

    (actual email changed to protect the innocent)

    I know the address is valid because using Outlook to send an email there works perfectly.   The person also confirms getting the email.

    BUT using System.net.mail,  an error message is thrown claiming the email is not valid.

    All other email addresses on system.net.mail appear to be working perfectly.

    How do I work around this problem?<sub></sub><sup></sup><strike></strike>

    <sub></sub><sup></sup><strike></strike>

    Sunday, June 16, 2019 2:42 PM

Answers

  • I have been working directly with Microsoft support on this issue.

    It is possible the problem is caused by the Framework.   Apparently the framework updates are not included in system updates.   So a Windows 7 machine may well have only  framework 3.5 which has an older version of system.net.mail.    I am told that using a framework of at least 4.5 may well solve the problem.   I am going to be testing that but it seems very likely that is the cause of the issue. 4.5 came out with Windows 8.   Current versions I believe are up to 4.8   I will update again if this does not solve the problem.

    Thank you to all who were kind enough to reply to this posting.  Hopefully this solution will help others as well.

    • Marked as answer by AWIcurrent Wednesday, November 27, 2019 2:16 PM
    Wednesday, November 27, 2019 2:15 PM

All replies

  • Find another email program, becuase maybe 'a' is not enough characters for the email program to consider  that yhe email address is valid.
    Sunday, June 16, 2019 2:51 PM
  • Thank you for the reply.

    As I stated the email address is valid.  Are you suggesting that I should use a substitute for system.net.mail?  If someone from Microsoft is reading this, I think then there is a bug in system.net.mail.

    What substitute program would you or others recommend?

    Outlook automation would seem a very slow way to send emails.   Perhaps Outlook has a subset that is just the sending function?

    Sunday, June 16, 2019 6:36 PM
  • Please show the complete code set for sending email via System.Net.Mail.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Sunday, June 16, 2019 6:47 PM
    Moderator
  • The code works perfectly with thousands of emails that we have sent out with it.  So showing the code here will not reveal anything.  We get an error message from system.net.mail that this particular email with a single letter followed by  @domain.com is invalid.  Yet the email is valid.   I had to write code to get the regex to accept the email address because it was also rejecting the address.   

    It clearly is how system.net.mail is deciding what is a valid email.

    This must be one of those edge cases that outlook can handle but system.net.mail has trouble with.

    I could write code to take the exception and run it through outlook, but that is messy  and I can not say I am a fan of doing that.

    I appreciate your interest in the problem.

    Monday, June 17, 2019 2:32 AM
  • Thank you for the reply.

    As I stated the email address is valid.  Are you suggesting that I should use a substitute for system.net.mail?  If someone from Microsoft is reading this, I think then there is a bug in system.net.mail.

    What substitute program would you or others recommend?

    Outlook automation would seem a very slow way to send emails.   Perhaps Outlook has a subset that is just the sending function?

    The email address may be valid in its usage in other solutions. But does the email program you are using consider the 'a'  a single character as the only character before the @ sign to be a valid length of characters before the @ sign? 

    It seems to be a possible built-in validation rule  issue with Net.Mail. You could use Outlook  Exchange server to send the emails.

    You could even use MS SQL Server to send emails by using its email stored procedure along with using ADO.NET to connect to MS SQL Server and execute the email stored procedure.

    https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-send-dbmail-transact-sql?view=sql-server-2017

    Monday, June 17, 2019 10:33 AM
  • It may be that Outlook does not use RFC5322 specification for checking email addresses while System.Net.Mail does and there is no override. Since this is the case you may very well be stuck with the ones which are being rejected.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, June 17, 2019 11:10 AM
    Moderator
  • What is the exact message and when do you get it(creation or sending)?

    Search Documentation

    SerialPort Info

    Multics - An OS ahead of its time.

     "Those who use Application.DoEvents have no idea what it does

        and those who know what it does never use it."    former MSDN User JohnWein

    Monday, June 17, 2019 12:39 PM
  • The error is coming up from the sending process.  It is coming from system.net.mail.

    It is stating the email address is not acceptable.

    I am off site now so I do not have the exact error message.

    Monday, June 17, 2019 1:05 PM
  • Can you provide the exact error message using SendCompleted event?

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, June 17, 2019 1:17 PM
    Moderator
  • Can you provide the exact error message using SendCompleted event?

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    Yes.  It would also be nice to know about the server that is handling the send request.  It might be that it is configured to disallow single character prefixes, though the actual prefix is not shown, 'to protest the innocent.'

    Search Documentation

    SerialPort Info

    Multics - An OS ahead of its time.

     "Those who use Application.DoEvents have no idea what it does

        and those who know what it does never use it."    former MSDN User JohnWein

    Monday, June 17, 2019 3:17 PM

  • Actually the a@ is exactly from the actual email address.   It is the domain that was changed to protect the innocent.

    I will check with the person who maintains the email server.  Where would one set acceptable addresses for outgoing emails in  IIS?

    Monday, June 17, 2019 3:43 PM

  • Actually the a@ is exactly from the actual email address.   It is the domain that was changed to protect the innocent.

    I will check with the person who maintains the email server.  Where would one set acceptable addresses for outgoing emails in  IIS?


    IIS? Didn't know that IIS was a SMTP server.  Why not use Outlook?  The SmtpClient class is obsolete.

    Search Documentation

    SerialPort Info

    Multics - An OS ahead of its time.

     "Those who use Application.DoEvents have no idea what it does

        and those who know what it does never use it."    former MSDN User JohnWein


    • Edited by dbasnett Monday, June 17, 2019 5:39 PM
    Monday, June 17, 2019 3:47 PM
  • I would be interested to know if the actual email address passes with the following online validator

    https://verifalia.com/validate-email

    Going back to Outlook, it may be that Outlook is simply ignoring some of the basic validation rules and allowing it to go.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, June 18, 2019 11:01 AM
    Moderator
  • I would be interested to know if the actual email address passes with the following online validator

    https://verifalia.com/validate-email

    Going back to Outlook, it may be that Outlook is simply ignoring some of the basic validation rules and allowing it to go.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    I don't think that there is anything wrong with a single character prefix, as long as that character follows the standards.  I have seen them used.

    Search Documentation

    SerialPort Info

    Multics - An OS ahead of its time.

     "Those who use Application.DoEvents have no idea what it does

        and those who know what it does never use it."    former MSDN User JohnWein

    Tuesday, June 18, 2019 1:01 PM
  • I would be interested to know if the actual email address passes with the following online validator

    https://verifalia.com/validate-email

    Going back to Outlook, it may be that Outlook is simply ignoring some of the basic validation rules and allowing it to go.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    I don't think that there is anything wrong with a single character prefix, as long as that character follows the standards.  I have seen them used.

    Search Documentation

    SerialPort Info

    Multics - An OS ahead of its time.

     "Those who use Application.DoEvents have no idea what it does

        and those who know what it does never use it."    former MSDN User JohnWein

    Try running the validator, there are over five issues with the address the poster supplied.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, June 18, 2019 1:23 PM
    Moderator
  • I would be interested to know if the actual email address passes with the following online validator

    https://verifalia.com/validate-email

    Going back to Outlook, it may be that Outlook is simply ignoring some of the basic validation rules and allowing it to go.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    I don't think that there is anything wrong with a single character prefix, as long as that character follows the standards.  I have seen them used.

    Search Documentation

    SerialPort Info

    Multics - An OS ahead of its time.

     "Those who use Application.DoEvents have no idea what it does

        and those who know what it does never use it."    former MSDN User JohnWein

    Try running the validator, there are over five issues with the address the poster supplied.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    I clicked the link you provided and used

    a@booco.com

    as the address.  It looked ok to me.


    Search Documentation

    SerialPort Info

    Multics - An OS ahead of its time.

     "Those who use Application.DoEvents have no idea what it does

        and those who know what it does never use it."    former MSDN User JohnWein

    Tuesday, June 18, 2019 2:12 PM
  • I would be interested to know if the actual email address passes with the following online validator

    https://verifalia.com/validate-email

    Going back to Outlook, it may be that Outlook is simply ignoring some of the basic validation rules and allowing it to go.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    I don't think that there is anything wrong with a single character prefix, as long as that character follows the standards.  I have seen them used.

    Search Documentation

    SerialPort Info

    Multics - An OS ahead of its time.

     "Those who use Application.DoEvents have no idea what it does

        and those who know what it does never use it."    former MSDN User JohnWein

    Try running the validator, there are over five issues with the address the poster supplied.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    I clicked the link you provided and used

    a@booco.com

    as the address.  It looked ok to me.


    Search Documentation

    SerialPort Info

    Multics - An OS ahead of its time.

     "Those who use Application.DoEvents have no idea what it does

        and those who know what it does never use it."    former MSDN User JohnWein

    Not for me

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, June 18, 2019 2:44 PM
    Moderator
  • Validation summary

     

    Classification:

    Undeliverable
    Status:
    Possibly invalid email address, a timeout has occurred while connecting to the mail exchanger which serves the e-mail address domain.
    Status code:
    SmtpConnectionTimeout (What's this?)

    Wednesday, June 19, 2019 2:32 AM

  • Wednesday, June 19, 2019 3:00 AM


  • According to error message, the syntax of the real address seems invalid.

     

    For example, maybe it contains a special ‘@’ (FF20) instead of ‘@’. Or maybe it ends with ‘\r’ or ‘\n’.

    Wednesday, June 19, 2019 5:47 AM
  • Wonder why I don't get same results

    and another


    Search Documentation

    SerialPort Info

    Multics - An OS ahead of its time.

     "Those who use Application.DoEvents have no idea what it does

        and those who know what it does never use it."    former MSDN User JohnWein

    Wednesday, June 19, 2019 3:02 PM
  • Yea, I looked at that.  Sadly it is typed and handled correctly.

    The issue seems to be with the MailAddressParser.   The code is already checking for valid email formats before the emails are sent, so the parser is redundant at best.  is there a way to get around the MailAddressParser?

    Wednesday, June 19, 2019 8:32 PM
  • Yea, I looked at that.  Sadly it is typed and handled correctly.

    The issue seems to be with the MailAddressParser.   The code is already checking for valid email formats before the emails are sent, so the parser is redundant at best.  is there a way to get around the MailAddressParser?

    MailAddressParser is marked as internal (private) so no there is no getting around it. Perhaps trying MailKit.

    http://www.mimekit.net/docs/html/Introduction.htm

    Only thing is all samples are in C#.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, June 19, 2019 8:49 PM
    Moderator
  • Yea, I looked at that.  Sadly it is typed and handled correctly.

    The issue seems to be with the MailAddressParser.   The code is already checking for valid email formats before the emails are sent, so the parser is redundant at best.  is there a way to get around the MailAddressParser?

    If even ‘var a = new System.Net.Mail.MailAddress( "some EMail address" )’ gives the exception, then the real string is probably invalid.


    Wednesday, June 19, 2019 9:08 PM
  • I have been working directly with Microsoft support on this issue.

    It is possible the problem is caused by the Framework.   Apparently the framework updates are not included in system updates.   So a Windows 7 machine may well have only  framework 3.5 which has an older version of system.net.mail.    I am told that using a framework of at least 4.5 may well solve the problem.   I am going to be testing that but it seems very likely that is the cause of the issue. 4.5 came out with Windows 8.   Current versions I believe are up to 4.8   I will update again if this does not solve the problem.

    Thank you to all who were kind enough to reply to this posting.  Hopefully this solution will help others as well.

    • Marked as answer by AWIcurrent Wednesday, November 27, 2019 2:16 PM
    Wednesday, November 27, 2019 2:15 PM