SMTP服务器如何工作? 需要了解

我正在寻找理解如何SMTP服务器的工作原理。

例如,如果我希望在Windows 2008上只运行一个显式的应用程序(运行在它的Web服务器,应用程序服务器和数据库服务器上)上运行SMTP服务器,是否需要注册该域以发送来自我的域的电子邮件,如果我想从该SMTP服务器发送电子邮件给某些用户?

不,你不需要注册。 您可以安装一个SMTP服务器,并立即开始发送电子邮件。 有些事情你应该做,以避免被标记为垃圾邮件:

  1. 使用一个静态的外部IP地址。 一些SBL将阻止来自已知dynamicIP地址的电子邮件
  2. 设置SPF DNSlogging
  3. 为服务器发送邮件的IP地址设置反向DNS条目

如果您不需要通过您的smtp服务器接收来自其他人的电子邮件,则无需注册您的域名。 如果您只需要发送电子邮件,则可以将您的smtp服务器用于您的应用程序服务器。 但是您需要configuration您的smtp服务器关于应用程序服务器的身份validation和中继。

关于身份validation,如果你的smtp服务器和应用程序是不同的机器,你的configuration允许匿名login,除了你的服务器在同一个域。

关于中继,你的configuration允许只有你的应用服务器可以中继到你的smtp服务器。

在设置authentication和中继之后,您使用cdo对象编写代码来发送电子邮件

如下所示,由smtp服务器发送电子邮件的示例asp代码。

<!-- 'Sending SMTP mail via port 25 using CDOSYS 'This ASP page uses CDOSYS to send SMTP mail using port 25 of the SMTP server that is set. The e-mail delivery is handled by the SMTP server that is set in the configuration object. --> <%@ Language=VBScript %> <HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"> </HEAD> <BODY> <% ' send by connecting to port 25 of the SMTP server Dim iMsg Dim iConf Dim Flds Dim strHTML Dim strSmartHost Const cdoSendUsingPort = 2 StrSmartHost = "mail.example.com" set iMsg = CreateObject("CDO.Message") set iConf = CreateObject("CDO.Configuration") Set Flds = iConf.Fields ' set the CDOSYS configuration fields to use port 25 on the SMTP server With Flds .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSmartHost .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10 .Update End With ' build HTML for message body strHTML = "<HTML>" strHTML = strHTML & "<HEAD>" strHTML = strHTML & "<BODY>" strHTML = strHTML & "<b> This is the test HTML message body</b></br>" strHTML = strHTML & "</BODY>" strHTML = strHTML & "</HTML>" ' apply the settings to the message With iMsg Set .Configuration = iConf .To = "[email protected]" .From = "[email protected]" .Subject = "This is a test CDOSYS message (Sent via Port 25)" .HTMLBody = strHTML .Send End With ' cleanup of variables Set iMsg = Nothing Set iConf = Nothing Set Flds = Nothing %> <P> </P> </BODY> </HTML> 

你也可以使用asp.net代码。 search关于CDO对象…

是的,您一定需要注册您将要发送电子邮件的域名。 将发件人地址与未注册的域一起使用会使您的邮件成为收件人的垃圾邮件文件夹的一stream单程票。