I have a table storing email variables/values that are called through powershell queries in my script. 

```
Send-MailMessage -From $From_Email -To $To_Email -Subject $Job_Success_Email_Subject -Body $Email_Body -SmtpServer $SmtpServer -port $SmtpPort -Credential $SmtpCredentials -usessl

```

I am mainly interested in the Username/Password credentials being passed from DB, but i have been getting this error when using `Get-Credential`:

```
$SmtpCredentials = Get-Credential

```

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

if i pass in my credentials from DB like this instead:

```
$SmtpPassword = $SmtpPassword | ConvertTo-SecureString -AsPlainText -Force

$SmtpCredentials = New-Object System.Management.Automation.PSCredential($SmtpUser,$SmtpPassword)

```

Note: the password is NOT encrypted for now just for testing purposes!

i get these 2 errors:

> 
> New-Object : Cannot find an overload for "PSCredential" and the
>  argument count: "2".
> 
> 
> 

and then i get a Credential popup login, and if i enter nothing, i get this error:

> 
> Send-MailMessage : Cannot validate argument on parameter 'Credential'.
>  The argument is null or empty. Provide an argument that is not null or
>  empty, and then try the command again.
> 
> 
> 

if I do enter the credentials manually, i get this instead:

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

I know this error has threads discussed and answered, but I have gone through all possible solutions, such as `usessl` and the `ConvertTo-SecureString -AsPlainText -Force` but its not working. I have also tried `[string][ValidateNotNullOrEmpty()]$SmtpPassword` but that seems to have no effect either. 

So for now, in order to ensure that its not an issue with the credentials itself, i would like to test with something like `Integrated Security=SSPI` like sql connection string allows but for the Send-Mail command