对 SMTP / IIS 以及通过 ASP 发送电子邮件实际发生的情况感到困惑

发布于 2024-12-08 18:24:54 字数 424 浏览 1 评论 0原文

我有一台 Windows 2003 / IIS 6.5 机器,运行一个经典的 ASP 站点。

该网站本身会发送电子邮件(“忘记密码”等),我还在计算机上运行脚本来发送电子邮件新闻通讯。

我在发送方面没有真正的问题...但我对电子邮件的实际工作方式感到困惑。

当我从我的网站发送邮件时(我不提供任何登录信息),SMTP 服务器 (IIS) 是否与我的电子邮件提供商(gmail for Business)进行通信?我的 IIS SMTP 服务器是否只是将电子邮件发送出去(也许对目标进行 MX 查找?)? DNS 记录中的 SPF 记录允许这样做吗?

我刚刚重建了我们的服务器(灾难后)并将我们的电子邮件移至 gmail...所以,我现在正在设置这一切...我可以阅读所有“操作方法”文章 - 但除非我理解一些简单的概念,我真的不知道自己在做什么。

谢谢!

I have a windows 2003 / IIS 6.5 machine running a classic ASP site.

The site itself sends emails ('forgot password', etc.) and I also run scripts on the machine to send email newsletters.

I don't have a real problem sending... but I am confused about how emailing actually works.

Is the SMTP server (IIS) ever communicating with my email provider (gmail for business) when I send from my website (I don't provide any login info)? Does my IIS SMTP server just blast emails out (maybe doing an MX lookup for the target?)? Is it the SPF record in the DNS records that allows this?

I just rebuilt our server (after disaster) and moved our email to gmail... so, I am setting this all up now... I can read all the 'how-to' articles - but unless I understand a few simple concepts, I won't really know what I am doing.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挽你眉间 2024-12-15 18:24:54

向某人发送邮件时,会涉及两个 SMTP 服务器。

  • 您自己的 SMTP 服务器(发件人)
  • 收件人 SMTP 服务器(收件人)

基本上,当您从邮件客户端发送邮件时,您的邮件客户端会将邮件发送到您自己的 SMTP 服务器,然后该服务器将邮件发送到收件人 SMTP 服务器。出现此(跃点)的原因是因为服务器可能会关闭/速度缓慢/等等,而您自己的服务器现在的责任是尝试(通常)在 48 小时内递送邮件。

要找出收件人拥有的 SMTP 服务器,发件人 SMTP 会查找收件人域的 MX 记录:

C:\> nslookup -type=mx hotmail.com
Server:  dns.server.com
Address:  183.255.245.11

Non-authoritative answer:
hotmail.com     MX preference = 5, mail exchanger = mx1.hotmail.com
hotmail.com     MX preference = 5, mail exchanger = mx2.hotmail.com
hotmail.com     MX preference = 5, mail exchanger = mx3.hotmail.com
hotmail.com     MX preference = 5, mail exchanger = mx4.hotmail.com

如您所见,可以为一个域指定多个 SMTP 服务器(用于冗余),并且发件人SMTP 将根据优先级选择一个(有效的)。然后邮件被发送到该服务器。

并且(如果不使用网络邮件)收件人邮件客户端可以使用 POP3 或 IMAP 协议下载该邮件。

现在,当您从 ASP.NET 发送邮件时,发件人 SMTP 服务器通常是本地 IIS SMTP服务,而不是您所在域的常用 SMTP 服务器(您自己用来发送邮件的服务器;在您的实例中为 Gmail)。

SPF 记录是添加到您的 DNS 的记录,用于指定允许哪些 SMTP 服务器从您的域发送邮件。通常,如果您指定它们,接收方 SMTP 服务器会强制将发件人 SMTP 服务器列在发件人地址中的域的 SPF 记录中。但是,如果您没有指定它们,邮件通常会被允许通过,并且其他垃圾邮件归档程序会介入。

无论如何,希望这有助于澄清事情......

When sending a mail to someone, there's two SMTP servers involved.

  • Your own SMTP server (sender)
  • The recipients SMTP server (receiver)

Basically, when you send a mail from your mailclient, your mailclient sends the mail to your own SMTP server, which then sends the mail to the recipients SMTP server. The reason for this (hop) is because servers may be down/slow/etc and your own server's responsibility is now to try and deliver the mail for (usually) within 48 hours.

To find out what SMTP server the receipient has, the MX-records are looked up, by the sender SMTP, for the recipients domain:

C:\> nslookup -type=mx hotmail.com
Server:  dns.server.com
Address:  183.255.245.11

Non-authoritative answer:
hotmail.com     MX preference = 5, mail exchanger = mx1.hotmail.com
hotmail.com     MX preference = 5, mail exchanger = mx2.hotmail.com
hotmail.com     MX preference = 5, mail exchanger = mx3.hotmail.com
hotmail.com     MX preference = 5, mail exchanger = mx4.hotmail.com

As you can see, multiple SMTP servers can be specified for a domain (for redundancy), and the sender SMTP will pick one based on priority (one that works). The mail is then sent to that server.

And (if not using a webmail) the recipients mailclient may download that mail using e.g. POP3 or IMAP protocols.

Now, when you send a mail from ASP.NET the sender SMTP server is usually the local IIS SMTP service, and not the usual SMTP server for your domain (the one that you yourself use to send mail; in your instance Gmail).

SPF-records are records added to your DNS to specify what SMTP servers are allowed to send mail from your domain. Usually, IF you specify them, the receiver SMTP servers force that the the sender SMTP server is listed in the SPF record for the domain in the from-address. If you don't specify them however, mail is usually let though anyway, and other SPAM-filers kick in.

Anyway, hope this helps to clarify things...

长不大的小祸害 2024-12-15 18:24:54

开箱即用,IIS 6 将使用内置的 SMTP 服务器发送,经典 ASP 通常默认使用拾取目录 x:\inetpub\mailroot\pickup\。 ASP 在这里创建一个电子邮件文件,当 SMTP 服务检测到它时,邮件就会被移动以进行处理。如果您停止“简单邮件传输协议”服务,您应该会看到文件备份在此处,再次启动将使它们全部消失。

SMTP 虚拟服务器将出现在 IIS 管理中,从那里您可以将其设置为使用您的 google 帐户作为转发器,或者更好的是,您应该调整您的邮件功能以使用 SMTP 发送到 Google 而不是本地。假设您正在使用 CDOSYS,请使用以下代码指定邮件服务器和登录详细信息:

Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message") 

'This section provides the configuration information for the remote SMTP server.

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.yoursite.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

' If your server requires outgoing authentication uncomment the lines bleow and use a valid email address and password.
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="[email protected]"
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword"

ObjSendMail.Configuration.Fields.Update

'End remote SMTP server configuration section==

ObjSendMail.To = "[email protected]"
ObjSendMail.Subject = "this is the subject"
ObjSendMail.From = "[email protected]"

' we are sending a text email.. simply switch the comments around to send an html email instead
'ObjSendMail.HTMLBody = "this is the body"
ObjSendMail.TextBody = "this is the body"

ObjSendMail.Send

Set ObjSendMail = Nothing 

您应该时常监视您的邮件根文件夹中的“队列”和“死信”文件夹,即使唯一的操作是清除它们。

Out of the box, IIS 6 will send using the built in SMTP server, Classic ASP usually default to using the pickup directory x:\inetpub\mailroot\pickup\. ASP creates an email file in here and when the SMTP service detects it, the mail is moved for processing. If you stop the 'Simple Mail Transfer Protocol' service, you should see files backing up in here, starting it again will make them all go out.

The SMTP Virtual server will appear in IIS Management, and from there you can set it to use your google account as a forwarder, or better still, you should adjust your mail function to use SMTP to Google instead of local. Presuming that you are using CDOSYS, use the following code to specify a mail server and logon details:

Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message") 

'This section provides the configuration information for the remote SMTP server.

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.yoursite.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

' If your server requires outgoing authentication uncomment the lines bleow and use a valid email address and password.
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="[email protected]"
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword"

ObjSendMail.Configuration.Fields.Update

'End remote SMTP server configuration section==

ObjSendMail.To = "[email protected]"
ObjSendMail.Subject = "this is the subject"
ObjSendMail.From = "[email protected]"

' we are sending a text email.. simply switch the comments around to send an html email instead
'ObjSendMail.HTMLBody = "this is the body"
ObjSendMail.TextBody = "this is the body"

ObjSendMail.Send

Set ObjSendMail = Nothing 

Source

You should monitor your mailroot folder from time to time, for the 'queue' and 'badmail' folders, even if the only action is to clear them out.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文