-1

I wrote a code in .NET to send emails in my application:

Oxygenne + ASP.Net:

    mensagem:=MailMessage.Create(configemail[1],toUsers);
    mensagem.Subject:=title;
    mensagem.Body:=body;
    mensagem.IsBodyHtml:=IsBodyHtml;

This works fine when configemail[1] is something like "myemail@gmail.com". However, I have the need to send emails without using domain, something like "myemail". I am getting this error:

The specified string is not in the form required for an e-mail address

I believe this happens because the code validates if the variable has @anydomain in the string.

Am I able to override it, and let the user try to send emails without usind "@domain" in their address?

Arturio
  • 418
  • 1
  • 7
  • 25

1 Answers1

0

So far as I'm aware, SMTP requires all recipient mailboxes to have a domain part. You may be able to interact with a specific mail system via other protocols that allows you to interact with just local mailboxes but you shouldn't expect SMTP tools to be the means of doing so.

Per RFC 5321:

Only resolvable, fully-qualified domain names (FQDNs) are permitted when domain names are used in SMTP ... There are two exceptions to the rule requiring FQDNs

The reserved mailbox name "postmaster" may be used in a RCPT command without domain qualification

Which in turn leads us to the syntax for the RCPT command:

rcpt = "RCPT TO:" ( "<Postmaster@" Domain ">" / "<Postmaster>" /
              Forward-path ) [SP Rcpt-parameters] CRLF

So, the only generally applicable form that is available is the Forward-Path, which via a few hops (and ignoring some legacy options not helpful to you here) leads us to the Mailbox syntax:

Mailbox        = Local-part "@" ( Domain / address-literal )

So, either way you have to have the @ and then your choices boil down to a domain name or an IP address. Note that this may give us an opening though - you may be able to get what you want by specifying the addresses as myemail@127.0.0.1.

Community
  • 1
  • 1
Damien_The_Unbeliever
  • 234,701
  • 27
  • 340
  • 448