Email address shows up as null null
Why does my email end in @null ? - Gmail Community
What is null in emails - Google Account Community
NULL alongside my email address
Options like
null@,devnull@, ornone@seem plausible, but there's a concern that these addresses might already be in use.
None of those are standard and they indeed might be already in use.
As far as I know, there is no special address that would guarantee non-delivery when sending to arbitrary random domains – any syntactically-valid "local-part" is equally valid for delivery, and only the receiving MTA can decide whether to accept it; the sending MTA cannot refuse based on local-part.
So in all cases, you'll have to decide on a specific (sub)domain first.
Suggestions:
Set up an MTA at your own domain name (or a subdomain thereof; you can put MX records on subdomains). You'll then have a guarantee that e.g.
null@will not be in use at that particular domain. Of course, the sender will still try to contact you, but you can literally alias that mailbox to/dev/nullon your end.There is now a recent convention of creating a "null MX" record on domains that are explicitly never expected to receive email (as opposed to domains that have no MX records, in which case the domain would be implicitly its own MX). If you create a single MX record that points to the server
., this will cause many new MTAs to automatically fail delivery. Again, you can use a subdomain for this instead of dedicating a whole domain.example.com(and.net, and.org) is a real domain that exists, but is reserved for usage in examples and documentation (i.e. it'll never have real mailboxes); as part of that, it actually has a "null MX" record.There are reserved domains, such as
[anything].invalid, which will never exist in DNS at all (not even as null-MX) and therefore your origin MTA will immediately fail delivery.
Since the question mentions Postfix MTA, here is how to set up Postfix to have a particular address behave as if it was an equivalent of /dev/null.
The Postfix comes with a discard mail delivery agent, which is described as:
The discard(8) delivery agent pretends to deliver all recipients in the delivery request, logs the "next-hop" destination as the reason for discarding the mail, updates the queue file, and either marks recipients as finished or informs the queue manager that delivery should be tried again at a later time.
An e-mail address can be configured to be handled by the discard agent by using the transport maps:
/etc/postfix/main.cf:
transport_maps = hash:/etc/postfix/transport
/etc/postfix/transport:
[email protected] discard:
Then execute postmap /etc/postfix/transport to create indexed file of the transport database and reload the Postfix daemon (the command for reloading or restarting a daemon could vary depending on the operating system being used).
As a result, Postfix will discard mail addressed to [email protected].
Mail for entire domain or subdomains can be discarded in this way:
/etc/postfix/transport:
# discard all mail to domain 'example.com':
example.com discard:
# discard all mail to subdomains of 'example.com':
.example.com discard:
You cannot do this with SmtpClient and MailMessage, so using this or Send-MailMessage is out of the question. Unfortunately that means you're left with either finding a third party library which does support it, or writing the code yourself to send directly through SMTP.
You're probably better off testing this part of your system with a unit test.
Manually with telnet
open localhost 25
HELO Foo
MAIL FROM: <> <--- the null address
Automated.
Not actually the complete working code, but should give the general impression GetFile and SmtpStream are streams. The solution is to feed an pre-created .eml file by directly interacting with the SMTP protocol.
GivenAClientIsConnectedToAnAgentInTheWAITINGState();
SmtpStream.WriteAsciiString("MAIL FROM:<>{0}", Environment.NewLine);
SmtpStream.ReceiveAsAsciiString();
SmtpStream.WriteAsciiString("RCPT TO:<{0}>{1}",mailboxAddress, Environment.NewLine);
SmtpStream.ReceiveAsAsciiString();
SmtpStream.WriteAsciiString("DATA{0}", Environment.NewLine);
SmtpStream.ReceiveAsAsciiString();
SmtpStream.SendEmail(_fileRepository.GetFile("NullSenderMessage.eml"));
SmtpStream.SendDataTerminator();
SmtpStream.ReceiveAsAsciiString();
SmtpStream.WriteAsciiString("QUIT");