-
What is mail relaying?
Mail relaying occurs when mail is forwarded from someone
else through your mail server. Forwarding mail through a
mail server is ok as long as either the originator of the
message or the receiver is a local user. If neither the
originator nor the receiver of the message is a local user,
it is called third-party mail relaying. Under the hood, it
happens like this:
HELO your.smtp.server
wodSmtpServer replies
with 250
wod.smtp.server
The remote host sends the "From" part of the
envelope: MAIL
FROM:<joe@unknown.place.net> Your host responds
with: 250 ok
The remote host now sends one
or more RCPT TO commands, which specify the recipients of
the message: RCPT
TO:<bob@elsewhere.com> hold on! elsewhere.com is not domain you
want to accept messages for. So, what should you do? You
can accept the message with 250
ok or you can
reject it with 553 sorry, we do
not relay
In the first case, your server is acting as a relay:
it's accepting and agreeing to try to deliver a message
that's not destined for a domain that your server
hosts. In the second case, it's refusing to act as a
relay.
What is open relay?
An SMTP server is an "open relay" if it agrees to
relay mail no matter who's sending it and who is
receiving it. Open relay will accept and try to deliver it
to destination anyway.
Why shouldn't I be open relay?
Because of the spammers, mass-mailers and unsolicited
commercial e-mail. Rather than using their own bandwidth,
they seek open relays that will accept single message, and
then try to distribute it to, for example, 1 million
recipients - using your resources. Not only this causes a
problem for your bandwidth, but it is possible that other
hosts on the internet put you on blacklist for being open
relay (look at http://www.ordb.org for example) and refuse
to accept your messages even if when valid.
Is wodSmtpServer (open) relay?
Not at all. wodSmtpServer, by default, does NOT relay email
at all. This is up to your implementation. You need to
explicitly put received message to be relayed. If you
don't do that, wodSmtpServer will just save the message
locally.
So how do I relay messages?
Basically, it is enough to use this command in, for
example, MailReceived event:
wodSmtpServer1.Relays.Add
User.Message
and wodSmtpServer will try to relay received message for
you. You should also set wodSmtpServer1.DNSHostname
property with valid DNS server.
This is all you need if you want relaying. Optionally, you
can use Relay's Hostname, MailTo, MailReceived,
IdleWait.... properties to 'tweak' relaying
process, if needed.
How does it work, under the hood?
When you add message to be relayed, wodSmtpServer will do
few steps until message is successfully deliever, or until
it gives you an error on why relaying didn't succeed.
These are the steps:
1. After you used 'Add' method to add the message,
wodSmtpServer will wait for IdleWait seconds before it does
anything
2. It will try to retrieve domain information from address
provided in MailTo property
3. It will request DNS query to retrieve MX (Mail
Exchanger) records for that domain
4. When MX is found, it will resolve hostname retrieved as
MX record to IP address, and connect to it
5. When connected, it will use HELO, MAIL FROM, RCPT TO,
DATA, QUIT commands to post the message
If no error occurs, relaying is finished, RelayDone event
will be fired and you have nothing to do.
If error occurs, then:
- if connection to server fails, it will use another MX if
available - depends on DNS entries
- if there is not MX record for the domain, it will try to
retrieve A record, or just try to connect blindly to domain
address, assuming it's a hostname
If you want, you can change Hostname property so that
wodSmtpServer connects to that defined hostname (instead of
MX record information), thus using Hostname as
'smarthost' SMTP server.
No additional steps are required to relay email.
|