Getting your message onto the Internet...
To get your message out onto the Internet, it must be submitted
to an SMTP server. The SMTP class of
FreeSMTP.Net needs the
address of a mail server that will accept your message. In
the previous examples we have specified the mail server as mail.yourdomain.com. Of course your mail server will be
different, so be sure to change this in your code.
The role of the mail server is to accept your message and see
that it gets delivered to the recipient. If the recipient is
local (i.e. the same domain as the mail server) the process is all
handled internally by the mail server. If the recipient is
located outside of your mail server's domain (usually the case),
the mail server will find and contact the recipient's mail server
and deliver the message to it. This process is called
"relaying".
The number one problem that trips up most developers trying to
build their first mail enabled application, is that their mail
server rejects the messages that are sent to it by their
application.
Mostly every mail server on the Internet employs some type of
"relay" security. This security prevents spammers from using
your mail server as a gateway to get their messages out on the
Internet. The side effect of this is that if your mail
server does not think that you or your application are authorized
to relay mail through it, it will reject your messages.
There are several different methods of employing security on mail
servers. Some mail servers will only accept mail from
certain IP addresses. Some may require your application to
authenticate itself by providing a user name and a password before
it will allow you to submit mail for non-local delivery.
Your mail server administrator should be able to tell you the type
of authentication employed.
In any event, if your messages are being rejected by your mail
server, you will need to diagnose the problem and take corrective
measures so that your server will accept your messages.
The SMTP class of the
FreeSMTP.Net assembly contains a LogFile
property which is very useful in debugging your applications.
Simply set the LogFile property to a file name and it will
automatically create a log of the SMTP conversation with the
server. By viewing this log in notepad, you can see exactly
what the problem is. i.e.:
smtp.LogFile="c:\\smtp log.txt"
Here is the output of a log file that I created:
Connect to server. mail.quiksoft.com
220 quiksoft.com MailSite ESMTP Receiver
EHLO domain.com
250-quiksoft.com
250-SIZE 0
250-ETRN
250-ENHANCEDSTATUSCODES
250-X-IMS 3 10398
250-DSN
250-VRFY
250-AUTH SCRAM-MD5 LOGIN CRAM-MD5 NTLM
250-AUTH=LOGIN
250 8BITMIME
MAIL FROM:<sender@domain.com>
250 2.0.0 sender@domain.com OK
RCPT TO:<recipient@domain.com>
501 5.7.1 This system is not configured
to relay mail from <sender@domain.com>
to <recipient@domain.com> for 69.80.22.132
The only item of interest here is the last line which clearly
indicates why the server rejected the message. The logging
capability or
FreeSMTP.Net will save you loads of time diagnosing
SMTP problems and is another feature that distinguishes the
FreeSMTP.Net classes from System.Web.Mail. System.Web.Mail
does not allow you to log the SMTP conversation and therefore is
of little help, when you experience problems.
Solving the relay problem...
If you are experiencing relaying problems, there are several
ways to solve them.
1. Mail server configuration
If your application will be running on the same IP or group of IP
addresses every time, your mail server administrator may be able
to configure the mail server to accept all mail from those IP
addresses.
2. Use a different SMTP server
You may have access to a different server that does not require
authentication, or one that has been previously setup to accept
messages from you. Another alternative is to install your
own dedicated SMTP server which will accept and deliver the
messages for you without question. One such server is
SMTP Express. There are many other benefits to using a
server like
SMTP Express. For example, since
SMTP Express
runs on the same computer as your application, you can submit
messages to
SMTP Express much faster than submitting them to a
remote mail server. In fact the SMTP class of
FreeSMTP.Net
contains a SubmitToExpress() method that will submit your
message to
SMTP Express via the file system, which will be about
10x faster than submitting through TCP/IP to a traditional mail
server. This means that your application will be more
responsive, because
SMTP Express will handle the delivery in the
background. Additionally,
SMTP Express is dedicated to your
application which means that your important outbound mail will not
be placed at the bottom of the queue of mail already being
processed by your main mail server. Among other benefits,
SMTP Express will automatically retry failed messages, enable you
to monitor the progress of your mail blast, and even send up to
256 messages simultaneously. For more information on
SMTP Express, visit
http://www.quiksoftcorp.com/smtpexpress.
3. Configure your application to authenticate itself with a
user name and password
Please read on to find out how to configure your application
to authenticate itself with a user name and password...
Page Navigator:
<< Back,
1,
2,
3,
4,
Next >>
|