解决send-MailMessage SMTP验证发送时的弹出窗口

简介:

大家在使用send-mailmessge 编写一些脚本的时候一般会使用匿名发送的方式,如下所示:

send-mailmessage -to "test@contoso.com" -from "test@contoso.com" -subject "mailtest" -SmtpServer mail.contoso.com

但是在smtpserver禁止匿名发送的情况下,应该怎么办呢?好多人说可以调用-credential参数。

但是在控制台默认输入-credential一般会弹出窗口提示输入密码,没办法调用到脚本里。有没有一种法可以将密码进行处理呢?

举例说明:

$password = convertto-securestring "password.2013" -asplaintext -force
$cred=new-object -typename System.Management.Automation.PSCredential -argumentlist "test",$password
send-mailmessage -to "test@contoso.com" -from "test@contoso.com" -subject "mailtest" -credential $cred -SmtpServer mail.contoso.com

这样可以很完美的调用一个使用SMTP验证的邮件发送脚本。



本文转自handsome7038 51CTO博客,原文链接:http://blog.51cto.com/lixiaosong/1322643

相关文章
关于basp21发送邮件需要smtp验证的问题。
% response.write("") Set bobj = Server.CreateObject("basp21") ' ASP response.write(bobj.
1106 0
|
2月前
|
Ruby
|
3月前
|
数据安全/隐私保护 Ruby
|
3月前
|
数据安全/隐私保护 Ruby
|
5月前
|
网络安全 数据安全/隐私保护
用smtp发送邮件,语法错误,无法识别命令。 服务器响应为:Authentication is re
用smtp发送邮件,语法错误,无法识别命令。 服务器响应为:Authentication is re
92 0
|
8月前
|
网络安全 数据安全/隐私保护 Python
|
8月前
|
Python
|
8月前
|
Python
|
8月前
|
Python