我将尝试使用 Powershell 脚本通过 Gmail SMTP 服务器发送电子邮件,但是我无法成功发送邮件。以下是我使用的脚本-
$EmailFrom = "bttpm@gmail.com"
$EmailTo = "kamlesh.bhatt@domain.com"
$Subject = "Notification from XYZ"
$Body = "this is a notification from XYZ Notifications.."
$SMTPServer = "smtp.gmail.com"
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("bttpm", "Password");
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)