I just set up for our servers that need to send mail, we have a smart host relay to sendgrid.
Part of the setup is done via PowerShell, part through the GUI. If you can direct me on how to configure the additional steps via PowerShell I would be keenly interested and would update this site.
Start by setting up the SMTP Server, which is managed by the IIS 6 Admin console, with these commands from an elevated PowerShell prompt:
Import-Module ServerManager Add-WindowsFeature SMTP-Server,Web-Mgmt-Console,WEB-WMI
Then follow the steps 2-8 on this SpiceWorks Post
I would test from every server that must send email. Here’s the PowerShell way to send a test email, using splatting by building $params as a hash table for the parameters then passing in @params. Note that values can be single quoted if they’re not expanding, meaning they’re not containing any variables.
$MyDomain = 'daveslog.com' $MyEmailPrefix = 'dcobb' $SMTPRelayServerName = 'SMTPSERVER1' $params = @{ From = "testing@$MyDomain" Subject = 'Testing SMTP relay from PowerShell' To = "$MyEmailPrefix@$MyDomain" SmtpServer = $SMTPRelayServerName Verbose = $true } Send-MailMessage @params
I want to do the whole process via PowerShell, and hope to investigate further.