Trying to send email with powershell

Need Help?

That's what we're here for! The goal of the Rogers Community is to help you find answers on everything Rogers. Can't find what you're looking for? Just ask!
cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
I've Been Around
Posts: 1

Trying to send email with powershell

Hello,

 

I'm trying to send email with powershell, I'm stuck on the authentication. Here's what I have so far

Send-MailMessage -To to@rogers.com -from from@rogers.com -Subject Test -SmtpServer "smtp.broadband.rogers.com"

 

It always tell me that

Send-MailMessage : The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Authentication required

 

I tried to add -credential using my from@progers + email password or even used my roger account without much luck.

 

Thanks in advance

Marcel

 

 

***Edited Labels***

Solved! Go to Solution.

Accepted Solutions
Highlighted
Resident Expert
Resident Expert
Posts: 14,168

Re: Trying to send email with powershell

Rogers internet requires authentication and SSL.

So in your powershell send string, you will need to indicate your credentials, as well as the use SSL flag.

 

 

Send-MailMessage -From FROM@Rogers.com -to to@email.com -Subject SUBJECT 
-Body BODY -SmtpServer smtp.broadband.rogers.com -port 465 -UseSsl 
-Credential (Get-Credential)

 

The only problem is.. that i know of.. is the credential part, is only a GET capable flag.. you cant put an actuall value.. it has to get at the time of the script run..

 

So makes it a little hard to automate it 😞 (if thats your intention)



View solution in original post


All Replies
Highlighted
Retired Moderator
Retired Moderator
Posts: 624

Re: Trying to send email with powershell

Hi @mlamontagne65

 

Welcome to the Community Forums!

 

You've come to the right to get assistance with your concern.

 

This might be something one of our Resident Experts @Gdkitty @Datalink might be able to assist with?

 

@RogersPrasana

 

Highlighted
Resident Expert
Resident Expert
Posts: 14,168

Re: Trying to send email with powershell

Rogers internet requires authentication and SSL.

So in your powershell send string, you will need to indicate your credentials, as well as the use SSL flag.

 

 

Send-MailMessage -From FROM@Rogers.com -to to@email.com -Subject SUBJECT 
-Body BODY -SmtpServer smtp.broadband.rogers.com -port 465 -UseSsl 
-Credential (Get-Credential)

 

The only problem is.. that i know of.. is the credential part, is only a GET capable flag.. you cant put an actuall value.. it has to get at the time of the script run..

 

So makes it a little hard to automate it 😞 (if thats your intention)



View solution in original post

Highlighted
I Plan to Stick Around
Posts: 47

Re: Trying to send email with powershell

Could try passing a PSCredential variable in script

 

$cred=New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "MyUserID", ("MyPassword" | ConvertTo-SecureString)