繁体   English   中英

Windows Server 2012 R2 Standard上的Localhost SMTP服务器不起作用

[英]Localhost SMTP server on Windows Server 2012 R2 Standard not working

新安装的Windows Server 2012 R2 Standard。 我通过本教程http://www.vsysad.com/2012/04/setup-and-configure-smtp-server-on-windows-server-2008-r2/设置了SMTP服务器,并使用以下powershell命令进行了测试:

Send-MailMessage -SMTPServer localhost -To receiver_mail -From sender_mail -Subject "This is a test email" -Body "Hi Japinator, this is a test email sent via PowerShell"

它工作了一段时间,但此刻不小心停止了工作。 试图逐步阅读本教程-一切正常。 在Powershell中进行测试时收到此错误消息:

Send-MailMessage : Unable to connect to the remote server
At line:1 char:1
+ Send-MailMessage -SMTPServer localhost -To receiver_email -From sender_email ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [
   ion
    + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage

正如上面的答案所暗示的,该问题是由于未启动SMTP服务。

我在2012年测试服务器上停止了SMTP服务,然后运行了Send-MailMessage命令并确认错误相同:

PS C:\Users\Admin> Send-MailMessage -SMTPServer localhost -To xxxxxxxxx@gmail.com -From blog@vsysad.com
-Subject "This is a test email" -Body "Hi, this is a test email sent via PowerShell"
Send-MailMessage : Unable to connect to the remote server
At line:1 char:1
+ Send-MailMessage -SMTPServer localhost -To xxxxxxxxx@gmail.com -From blog@vsysad ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpExcept
   ion
    + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage

要做的第一件事是检查服务是否正在运行:

PS C:\Users\Admin> get-service smtpsvc

Status   Name               DisplayName
------   ----               -----------
Stopped  smtpsvc            Simple Mail Transfer Protocol (SMTP)

按照以上说明,如果SMTP服务未运行,请运行以下命令将其启动:

PS C:\Users\Admin> start-service smtpsvc

然后将启动设置为自动。 运行以下命令以执行此操作:

PS C:\Users\Admin> set-service smtpsvc -StartupType Automatic

这将确保在服务器启动时SMTP服务自动启动。

您的SMTP服务器现在应该能够处理您的Send-mailMessage请求,并假设其余配置正确,则成功中继消息。

IIS6上的SMTP虚拟服务器未启动。 默认情况下,它不会自动启动。 可以根据此线程https://serverfault.com/questions/263546/automatically-start-smtp-server-in-iis进行自动启动

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM