so, here's my situation:
I have a completely isolated lab network that I have complete control over, consisting of a Server 2012 VM running Exchange 2013, a Windows 7 client VM running Outlook 2013, and an Ubuntu server (14.04-3 LTS) running postfix as its mail server. As these VMs
are completely isolated from everywhere, and are physically separated from the Internet, security concerns are very low.
My issue is that I need to be able to send complete email messages by scripting them. I am attempting to use the PowerShell Send-MailMessage cmdlet, and it's not working. I get the following output:
PS C:\Windows\system32> Send-MailMessage -From <user1>@email.local -To <user2>@linux.local -Subject "powershell 1600
test" -Body "sent from PS to linux" -SmtpServer email-server
Send-MailMessage : Mailbox unavailable. The server response was: 5.7.1 Unable to relay
At line:1 char:1
+ Send-MailMessage -From <user1>@email.local -To <user2>@linux.local -Subject " ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpFailed
RecipientException
+ FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
I did my homework, and found that there are some changes that need to be made to the default Exchange server to make this possible:
1. Add a "Relay" Receive Connector (per http://exchangeserverpro.com/how-to-configure-a-relay-connector-for-exchange-server-2010/)
2. Allow the "Relay" connector to relay for any recipient using" Get-ReceiveConnector "Relay" | Add-ADPermission -User "NT AUTHORITY\ANONYMOUS LOGON" -ExtendedRights "Ms-Exch-SMTP-Accept-Any-Recipient" (per http://serverfault.com/questions/476979/exchange-connector-wont-send-to-external-domains)
After making those changes, email is flowing back and forth properly from the Outlook thick client through the Exchange Server to the Ubuntu server (also to/from OWA.) All is well there.
But Send-MailMessage from PowerShell is getting the same error message. At this point, I've tried recreating the connector, checking the message tracking logs (nothing indicative), sniffing the network traffic to see if there really is anything going on the
wire (nothing at all, not even DNS lookups), and a few other things.
All this indicates to me is that there's still some Exchange configuration issue, but I don't know what it is. Any ideas?
(BTW - I don't *have* to use Send-MailMessage to accomplish the goal of sending emails via a script. It just seemed the mot promising method.)
Thanks in advance for any and all advice.
-Bruce D.