繁体   English   中英

使用 Powershell 将带有批处理文件的 Email 发送到 Gmail

[英]Send Email to Gmail with Batch File Using Powershell

我正在尝试使用批处理文件将 email 发送到 gmail,我得到了这个:

Send-MailMessage : The SMTP server requires a secure connection or the client was not authenticated. The server
response was: 5.7.0 Authentication Required. Learn more at
At line:1 char:1
+ Send-MailMessage -SmtpServer smtp.gmail.com -port 25 -UseSsl -Credent ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpExcept
   ion
    + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage 

有认证的东西。 不过,我把获取凭据放在那里。

批处理文件代码:

powershell -ExecutionPolicy ByPass -Command Send-MailMessage 
-SmtpServer smtp.gmail.com -port 25 -UseSsl 
-Credential (Get-Credential) 
-To ansorensen1118@gmail.com 
-From ansorensen1118@gmail.com 
-Subject Testing 
-Body 123

现在很清楚了。 您不需要端口,它是可选的。 在用户名下输入您的 email 地址,在密码下输入您的 email 密码。

powershell -ExecutionPolicy ByPass -Command Send-MailMessage -SmtpServer smtp.gmail.com -UseSsl -Credential (Get-Credential) -To ansorensen1118@gmail.com -From ansorensen1118@gmail.com -Subject Testing -Body 123

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM