如何在不提供密码的情况下使用 smtp 在批处理文件中发送邮件



我有一个批处理文件,该文件位于调度程序中,该文件始终会ping以表示存在新的构建,如果存在,它会在新构建时启动自动化。我想通过在批处理文件中添加发送邮件命令来获得通知,以了解调度程序批处理文件已选择新版本。

看看 Blat 命令行工具。它需要快速设置来记录SMTP服务器,端口,发件人地址等(或者如果您愿意,可以在每次调用中指定它们),但是一旦完成,您就可以使用非常简洁的命令。

例如:

SET EmailTo=my@email.com
REM Send an email notice that the setup has started along with a timestamp.
REM First parameter as a dash indicates we will provide the body text,
REM  otherwise we could specify a text file here and it will be the body.
Blat - -to %EmailTo% -subject "Setup Started" -body "Started on %DATE% - %TIME"
REM Do some stuff...
REM Send an email notice that the setup is complete along with a log file.
Blat "C:PathToLog.txt" -to %EmailTo% -subject "Setup Complete"

最新更新