这是我在网上找的代码(要用到nc.exe的):- @echo off
- set "life=test.conf"
-
- :start
- cls
- ::::::::::::::::::::::::::::::::::::::::
- :name_b
- title 批处理发送邮件→1/5
- cls
- set name=
- set /p name=请输入邮箱用户名:
- if *%name%==* goto name_b
- echo %name%|findstr "^[0-9a-zA-Z_-=]*$" >nul ||(echo 语法错误,任意键返回&pause>nul&goto name_b)
- echo 必须保证和上面base64编码前的是同一用户名
- :name__b
- set name_=
- set /p name_=请输入邮箱用户名(非base64编码的):
- if *%name_%==* goto name__b
-
- :pass_b
- title 批处理发送邮件→2/5
- cls
- set pass=
- set /p pass=请输入邮箱密码:
- if *%pass%==* goto pass_b
- echo %pass%|findstr "^[0-9a-zA-Z_-=]*$" >nul ||(echo 语法错误,任意键返回&pause>nul&goto pass_b)
-
- :sjr_b
- title 批处理发送邮件→3/5
- cls
- echo 格式为xxx@xxx.xxx 例如:test@test.com
- set sjr=
- set /p sjr=请输入收件人:
- if *%sjr%==* goto sjr_b
- echo %sjr%|findstr "^[0-9a-z]*\@[0-9a-z]*\.[a-z]*$" >nul ||(echo 语法错误,任意键返回&pause>nul&goto sjr_b)
-
- :zt_b
- title 批处理发送邮件→4/5
- cls
- set zt=
- set /p zt=请输入邮件的主题:
- if *%zt%==* goto zt_b
-
- :zw_b
- title 批处理发送邮件→5/5
- cls
- set zw=
- set /p zw=请输入邮件的正文:
- if *%zw%==* goto zw_b
-
-
- ::写nc调用的脚本
- >%life% echo helo cn-dos
- >>%life% echo AUTH LOGIN
- >>%life% echo %name%
- >>%life% echo %pass%
- >>%life% echo mail from: ^<%name_%@163.com^>
- >>%life% echo rcpt to: ^<%sjr%^>
- >>%life% echo data
- >>%life% echo From: %name_%@163.com
- >>%life% echo To: %sjr%
- >>%life% echo Subject: %zt%
- >>%life% echo MIME-Version: 1.0
- >>%life% echo Content-Type: text/plain
- >>%life% echo.
- >>%life% echo %zw%
- >>%life% echo .
- >>%life% echo quit
-
- pause
- cls
- echo 正在获取smtp.163.com的ip
- for /f "tokens=4 delims= " %%? in ('ping -n 1 smtp.163.com ^|find /i "Ping statistics for"') do (set "ip_=%%?")
- set "ip=%ip_::=%"
- if *%ip%==* (echo 没有获取到ip,可能网络有问题&pause>nul&goto :eof)
- echo %ip%|findstr "^[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*$">nul||(echo 没有获取到ip,可能网络有问题&pause>nul&goto :eof)
- echo ip获取完成
-
- echo 正在发送邮件
- ::nc连接smtp.163.com 25执行%life%中的命令发邮件
- nc -nvv %ip% 25 < %life%
- echo 发送完成,任意键开始继续发送
- del /f/q %life%>nul
- pause>nul&goto sjr_b
-
- goto :eof
复制代码 不过运行到最后一步就停止了 邮件发不出去了?那位大侠帮忙!!!谢谢!!! |