簡體   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