如果服务器上未加载SMTP,您如何发送电子邮件?

时间:2022-02-11 15:24:23

using the Code Snippet for sending email in VB.Net I have successfully sent an email from my local machine, but when I Upload it to my server I get a message that the email failed. We have a national relay server that is running SMTP and I am pointed at that server in both instances. The only differance that jump out at me between the two machines is that the server is not running SMTP. Do I need SMTP to be running on the server if I am using a relay server to send the email that is running SMTP?

使用代码片段在VB.Net中发送电子邮件我已成功从本地计算机发送电子邮件,但当我将其上传到我的服务器时,我收到一条消息,表明电子邮件失败了。我们有一个运行SMTP的国家中继服务器,我在两个实例中都指向该服务器。在两台机器之间跳出来的唯一不同之处是服务器没有运行SMTP。如果我使用中继服务器发送运行SMTP的电子邮件,是否需要在服务器上运行SMTP?

 Dim message As New MailMessage("DoNotReply@faa.gov", My.Settings.NotifyList, "Starting FalconCMSOffloader @ " & My.Settings.FacID & " - " & Now, "NM")
        Dim emailClient As New SmtpClient(My.Settings.EmailServerAddress)
        emailClient.Send(message)

2 个解决方案

#1


3  

You shouldn't need SMTP running locally, as the VB.Net code should just be using basic TCP/IP to communicate directly to the relay server.

您不应该需要在本地运行SMTP,因为VB.Net代码应该只使用基本TCP / IP直接与中继服务器通信。

It would be useful to see the error message, it is possible that the server does not have access to port 25 on the relay server (eg. due to the firewall configuration). Note that you can test this connectivity to some degree by launching telnet from the command line (on the server) as follows:

查看错误消息很有用,服务器可能无法访问中继服务器上的端口25(例如,由于防火墙配置)。请注意,您可以通过从命令行(在服务器上)启动telnet来在一定程度上测试此连接,如下所示:

telnet RelayServerAddress 25

There is also a chance that there is some authentication happening with the relay server when you run the code locally on your machine under your domain account that isn't able to happen when the code is running on the server under a local account (I'm making some big assumptions here).

当您在域帐户下本地运行代码时,中继服务器也可能会发生一些身份验证,当代码在本地帐户下的服务器上运行时无法执行此操作(I'我在这里做了一些大的假设)。

#2


1  

You should not need an smtp server on the server if you specify the relay server. Double check that My.Settings.EmailServerAddress is indeed pointing to the relay server.

如果指定中继服务器,则不应在服务器上使用smtp服务器。仔细检查My.Settings.EmailServerAddress是否确实指向中继服务器。

#1


3  

You shouldn't need SMTP running locally, as the VB.Net code should just be using basic TCP/IP to communicate directly to the relay server.

您不应该需要在本地运行SMTP,因为VB.Net代码应该只使用基本TCP / IP直接与中继服务器通信。

It would be useful to see the error message, it is possible that the server does not have access to port 25 on the relay server (eg. due to the firewall configuration). Note that you can test this connectivity to some degree by launching telnet from the command line (on the server) as follows:

查看错误消息很有用,服务器可能无法访问中继服务器上的端口25(例如,由于防火墙配置)。请注意,您可以通过从命令行(在服务器上)启动telnet来在一定程度上测试此连接,如下所示:

telnet RelayServerAddress 25

There is also a chance that there is some authentication happening with the relay server when you run the code locally on your machine under your domain account that isn't able to happen when the code is running on the server under a local account (I'm making some big assumptions here).

当您在域帐户下本地运行代码时,中继服务器也可能会发生一些身份验证,当代码在本地帐户下的服务器上运行时无法执行此操作(I'我在这里做了一些大的假设)。

#2


1  

You should not need an smtp server on the server if you specify the relay server. Double check that My.Settings.EmailServerAddress is indeed pointing to the relay server.

如果指定中继服务器,则不应在服务器上使用smtp服务器。仔细检查My.Settings.EmailServerAddress是否确实指向中继服务器。