jzrobbie
asked on
Sending email from a PC error
Hi,
I was trying to send emails through powershell on a computer PC01. and received error message blow
"InvalidOperation: (System.Net.Mail.SmtpClien t:SmtpClie nt) [Send-MailMessage], SmtpException"
I also tried to run the same script on another computer PC02 in the same subnet. it worked.
Both PCs can telnet to the smtp server on 25 successfully.
I have also tried to use ISP smtp to send email which was the same result PC01 didn't work with the same error. PC02 worked.
I checked the even log, no outstanding errors or warnings found.
I have also tried to turned off firewall and antivirus program without luck (which shouldn't be the issue as I can telnet to port 25 on the smtp server)
I was trying to send emails through powershell on a computer PC01. and received error message blow
"InvalidOperation: (System.Net.Mail.SmtpClien
I also tried to run the same script on another computer PC02 in the same subnet. it worked.
Both PCs can telnet to the smtp server on 25 successfully.
I have also tried to use ISP smtp to send email which was the same result PC01 didn't work with the same error. PC02 worked.
I checked the even log, no outstanding errors or warnings found.
I have also tried to turned off firewall and antivirus program without luck (which shouldn't be the issue as I can telnet to port 25 on the smtp server)
hmm, use better exception handling and output the exception message and when available also the inner exceptions. Something like
try {
#Send e-mail code..
}
catch {
Write-Host $_.Exception.Message
if ($_.Exception.InnerException) {
Write-Host $_.Exception.InnerException.Message
}
}
ASKER
Hi ste5an,
I have tried your code. And received similar error
+ CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClien t:SmtpClie nt) [Send-MailMessage], SmtpExcept
ion
+ FullyQualifiedErrorId : SmtpException,Microsoft.Po werShell.C ommands.Se ndMailMess age
I have tried your code. And received similar error
+ CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClien
ion
+ FullyQualifiedErrorId : SmtpException,Microsoft.Po
Some kind SMTP of setup error. First thing after rereading:
PORT 25???? This should be closed. And you should use 587/TCP (Message Submission for Mail), cause you're acting as MUA.
Then I would use a network sniffer to analyze, what is happening.
PORT 25???? This should be closed. And you should use 587/TCP (Message Submission for Mail), cause you're acting as MUA.
Then I would use a network sniffer to analyze, what is happening.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
https://social.technet.microsoft.com/Forums/ie/en-US/7242541e-5722-4064-86bf-a108daf8711a/sendmail-powershell-issues?forum=winserverpowershell
also, can you test if you are able to submit the email using telnet...
telnet smtp.domain.com 25
ehlo mydomain.com
mail from:testu@mydomain.com
rcpt to:recipient@theirdomain.c
data
This is a test.
.
quit
https://technet.microsoft.com/en-us/library/aa995718(v=exchg.65).aspx