I have a mail sending powershell script that works when i run it on my host computer.
But when i run it on my windows server VM its not working, i get an error saying : 5.7.0 Authentication Required
its weird that its working on my main pc but not in the cloud windows server VM
anyone has an idea why its not working in a VM?
$emailSmtpServer = "smtp.gmail.com" $emailSmtpServerPort = "587" $emailSmtpUser = "email@example.com" $emailSmtpPass = "xxxx" $emailFrom = "firstname.lastname@example.org" $emailTo = "email@example.com" $emailcc="firstname.lastname@example.org" $emailMessage = New-Object System.Net.Mail.MailMessage( $emailFrom , $emailTo ) $emailMessage.cc.add($emailcc) $emailMessage.Subject = "Service Monitor Status" $emailMessage.IsBodyHtml = $true $emailMessage.Body = "ii" $SMTPClient = New-Object System.Net.Mail.SmtpClient( $emailSmtpServer , $emailSmtpServerPort ) $SMTPClient.EnableSsl = $true #True in most cases check $SMTPClient.Credentials = New-Object System.Net.NetworkCredential( $emailSmtpUser , $emailSmtpPass ); $SMTPClient.Send( $emailMessage )