I am able to run the below sample script from command line when on the box but facing issues while attempting to run the same script from controlm.
# mailtest.ps1
$cmd='Send-MailMessage -Body "body" -To "to@abc.com" -From "from@abc.com" -Subject "subject" -SmtpServer "smtpserver.net" -Port 25
Invoke-Expression $cmd
Command line - working fine:
powershell -NoLogo -NonInteractive -File mailtest.ps1
ControlM - Error:
powershell -NoLogo -NonInteractive -File mailtest.ps1
Send-MailMessage : Unable to read date from the transport connection: net_io_connectionclosed
...
+ FullyQualifiedErrorId : SmtpException,Microsoft.Powershell.Commands.SendMailMessage
The network is behind firewall but I think that is not an issue here as the mail is being sent from command line without any issues.
What I have tried so far:
- Have enabled client/server for TLS 1.0,1.1,1.2 & SSL 2.0,3.0
- Have tried the port numbers - 25, 587 and 465 - none of them works in controlM
- Have tried invoking using -NoProfile and Bypass arguments as well
Any pointer on what I am missing here will be great help.