China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-25 06:50
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » p-mailsend_4.0.cmd (send email from command line, mass mailing\multiple attachments\anonymous) DigestII View 80,851 Replies 122
Original Poster Posted 2007-04-21 04:17 ·  中国 甘肃 张掖 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Code for version 4.0 & attachments are on floor 2

Code for randomly changing the sending address is on floor 94

Simple code explanation is on floor 19


--------------------------Mass mailing method----------------------------------------------
p-mailsend /u *@* /p * /t a.txt /s test /c * /a *

The format of a.txt is as follows:
a@163.com
b@qq.com
c@56.com
d@yahoo.com.cn
....

-------------------------------------------------------------------------------------

[ Last edited by vkill on 2007-11-18 at 05:53 PM ]
Recent Ratings for This Post ( 3 in total) Click for details
RaterScoreTime
bob1989 +2 2009-08-12 11:47
+1 2010-11-22 10:11
hueagle +1 2010-12-22 13:27
Floor 2 Posted 2007-04-21 04:17 ·  中国 甘肃 张掖 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
p-mailsend_v4.0 code

Correction:
Removed iget.vbs, so there will be no virus prompt now
Enhanced parameter verification, so when parameters are incorrect, there will be no unresponsive phenomenon
When a password needs to be entered, it is not displayed in plain text


::p-mailsend.cmd
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: p-mailsend_v4.0 ::
:: ::
:: Code by : vkill ::
:: Thanks : bjsh,est,lxmxm... ::
:: Source : http://www.vkill.net http://bbs.cn-dos.net ::
:: Function : Command-line email sending program (mass sending/multiple attachments/anonymous) ::
:: Principle: Principle of sending and receiving emails via telnet ::
:: Last Update: 2007-11-12 ::
:: Program Dependent Files: nc.exe;rar.exe;base64.exe ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

@echo off&endlocal&setlocal ENABLEDELAYEDEXPANSION
set "t_=test.conf"
::Here is the detailed setting for anonymous sending
set "anonymous="QQ mailbox administrator anonymous test" <10000@qq.com>"

call :del_
set "oneself=%~f0"
if "%1"=="" (
echo Please execute %oneself% /? at the command line to view detailed command line help
ping -n 5 127.1 >nul 2>nul
goto :eof
)
if "%1"=="/?" goto help
if "%1"=="-?" goto help
for %%? in (/h,-h,--h) do (if "%~1"=="%%?" goto help)
echo.
echo p-mailsend_v4.0 by:vkill
echo _________________________________________________

set/p=Dependency file integrity check...<nul
set "tools_name=nc.exe;rar.exe;base64.exe"
for %%? in (%tools_name%) do (
if *%%~$PATH:?==* if not exist %%? (
echo no, Missing file %%? &goto :sleep_
)
)
set/p=ok<nul&echo.

set/p=Analyze whether parameters are correct...<nul
set n=0
if not "%1"=="" (
:loop_ap
set/a n+=1
if "%1"=="/hu" (set "hu=on" &shift)
if "%1"=="/ht" (set "ht=on" &shift)
if "%1"=="/ch" (set "ch=on" &shift)
if "%1"=="/u" ((for /f "tokens=1-2 delims=@" %%a in ('echo %~2') do (set "user=%%a"& set "server=%%b")) &shift&shift)
if "%1"=="/p" (set "pass=%~2" &shift&shift)
if "%1"=="/t" (set "to=%~2" &shift&shift)
if "%1"=="/s" (set "subject=%~2" &shift&shift)
if "%1"=="/c" (set "content=%~2" &shift&shift)
if "%1"=="/a" (set "accessories=%~2" &shift&shift)
if not "%1"=="" (echo %~1|findstr "^/" >nul 2>nul ||(echo no, Parameter "%~1" is incorrect&goto :sleep_))
if !n!==10 (echo no, Parameter "%~1" is incorrect&goto :sleep_)
if not "%1"=="" (goto loop_ap)
)
set/p=ok<nul&echo.

set/p=Analyze whether necessary parameters are missing...<nul
for %%? in (user server to subject) do (if not defined %%? (echo no&goto :sleep_))
set/p=ok<nul&echo.
if not defined pass (
:inputpass
for /f "tokens=1 delims=:" %%? in ('findstr /N "=Hiddenpass.cmd_s=" "%oneself%"') do (more +%%? %oneself%>"%temp%\a")
for /f "tokens=1 delims=:" %%? in ('findstr /N "=Hiddenpass.cmd_e=" "%oneself%"') do (set/a "a=%%?-1" & more +!a! %oneself%>"%temp%\b")
findstr /V /B /E /G:"%temp%\b" "%temp%\a">"%temp%\pass.cmd"
start /wait cmd /k ""%temp%\pass.cmd" "!user!@!server!""
set/p password=<%temp%\pass
set "pass=!password:~9!"
if not defined pass goto inputpass
del /f/q "%temp%\pass" >nul 2>nul
del /f/q "%temp%\pass.cmd" >nul 2>nul
del /f/q "%temp%\a" >nul 2>nul
del /f/q "%temp%\b" >nul 2>nul
)

set/p=Verify whether this address supports sending emails...<nul
for /f "tokens=3-6 delims=," %%a in ('findstr "^::,%server%," "%oneself%"') do (
set "smtp=%%a"&set "port=%%b"&set "authentication_method=%%c"&set "max_z=%%d"
)
if not defined smtp (echo no&goto :sleep_)
set/p=ok<nul&echo.

set/p=Verify network connectivity...<nul
for /f "tokens=2 delims=" %%? in ('ping -n 1 %smtp% ^|findstr /i "^ping.*"') do (set "ip=%%?")
if not defined ip (echo no&goto :sleep_)
set/p=ok<nul&echo.

set/p=Verify telnet %smtp% %port% connectivity...<nul
>"%temp%\l%t_%" echo quit
nc -d -nvv %ip% %port% < "%temp%\l%t_%" >"%temp%\p-mailsend.log"
findstr . "%temp%\p-mailsend.log">nul 2>nul||(echo no&goto :sleep_)
set/p=ok<nul&echo.

set/p=Verify successful login...<nul
if "%authentication_method%"=="1" call :authentication_method1
copy "%temp%\%t_%" "%temp%\l%t_%">nul 2>nul
>>"%temp%\l%t_%" echo quit
nc -d -nvv %ip% %port% < "%temp%\l%t_%" >"%temp%\p-mailsend.log"
set n=0
for /f "tokens=1,2* delims=:" %%a in ('findstr /N . "%temp%\p-mailsend.log"') do (set "n=%%a"&set "x%%a=%%b")
set/a n-=1
echo "!x%n%!"|findstr "235 " >nul 2>nul ||(echo no, Error "!x%n%!"&goto :sleep_)
set/p=ok<nul&echo.

::Continue to write nc configuration file
>>"%temp%\%t_%" echo mail from: ^<%user%@%server%^>
if exist "%to%" (
for /f "tokens=*" %%? in ('findstr "^@" "!to!"') do (set "lto=%%?,!lto!")
)
if defined lto (set "to=!lto!")
for %%? in (!to!) do (>>"%temp%\%t_%" echo rcpt to: ^<%%?^>)
>>"%temp%\%t_%" echo data
if not defined hu (>>"%temp%\%t_%" echo From: %user%@%server%) else (>>"%temp%\%t_%" echo From: %anonymous%)
if not defined ht (>>"%temp%\%t_%" echo To: %to%)
>>"%temp%\%t_%" echo Subject: %subject%
>>"%temp%\%t_%" echo X-mailer: p-mailsend_v4.0
>>"%temp%\%t_%" echo Mime-Version: 1.0
>>"%temp%\%t_%" echo Content-Type: multipart/mixed;
>>"%temp%\%t_%" echo boundary="=====vkill====="
>>"%temp%\%t_%" echo.
>>"%temp%\%t_%" echo --=====vkill=====
if defined content call :htmlortxt !content!
>>"%temp%\%t_%" echo charset="gb2312"
>>"%temp%\%t_%" echo Content-Transfer-Encoding: 7bit
>>"%temp%\%t_%" echo.
if defined content (dir !content! >nul 2>nul &&(type "!content!">>"%temp%\%t_%" &>>"%temp%\%t_%" echo.) ||(>>"%temp%\%t_%" echo !content!)) else (>>"%temp%\%t_%" echo :^))

set z=0
if defined accessories set/p=Compressing and encoding attachments...<nul
echo "%accessories%" |findstr ")" >nul 2>nul && (echo no, Attachment path or file name cannot contain ^)&goto :sleep_)
if defined accessories (
for /f "tokens=1,2,3,4,5,6 delims=→" %%a in ('echo %accessories%') do (
call :compress_and_encode_attachment "%%~a"
call :compress_and_encode_attachment "%%~b"
call :compress_and_encode_attachment "%%~c"
call :compress_and_encode_attachment "%%~d"
call :compress_and_encode_attachment "%%~e"
call :compress_and_encode_attachment "%%~f" )
)
if defined xx (echo no, Compression or encoding of attachment error&goto :sleep_)
if not !z! lss %max_z% (echo Attachment is too large, %server% mailbox supports maximum attachment size of %max_z%K&goto :sleep_)
if defined accessories (set/p=ok<nul&echo.)
>>"%temp%\%t_%" echo --=====vkill=====--
>>"%temp%\%t_%" echo .
>>"%temp%\%t_%" echo quit

::Send email
set/p=Sending email...<nul
nc -d -nvv %ip% %port% < ""%temp%\%t_%"" >"%temp%\p-mailsend.log"
for /f "tokens=*" %%? in ("%temp%\p-mailsend.log") do (
if defined vk1 if not defined vk2 (set vk2=0&set "email_sending_error=%%?"&echo "%%?"|findstr "250 " >nul 2>nul ||(set vk3=0))
echo "%%?"|findstr "354 " >nul 2>nul &&(set vk1=0)
)
if defined vk3 (echo no, Error "!email_sending_error!"&goto :sleep_)
set/p=ok<nul&echo.

call :del_
echo _________________________________________________
echo Email sending completed, exiting in 2 seconds
ping -n 2 127.1 >nul 2>nul
goto :eof

::all call::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:help
echo.
echo p-mailsend_v4.0 2007.11 by:vkill Thanks to bjsh,est,lxmxm...
echo Copyright (C) 2006-2008 http://www.vkill.net http://bbs.cn-dos.net
echo Currently supported mailboxes: 21cn.com,sina.com,163.com,126.com,sohu.com,yahoo.com.cn,qq.com
echo Program dependent files: nc.exe;rar.exe;base64.exe
echo If dependent files are incomplete, please manually download to the windows directory from http://www.vkill.net/tools.html
echo.
echo Usage:
echo p-mailsend /u user@address /t recipient /s subject
echo.
echo /hu Anonymous sending
echo /ht Hide other recipients when sending to multiple parties
echo /u * Username@address Example:/u 122755990@qq.com
echo /p Password
echo /t * Recipient:(Recipient/text file path with written recipients)
echo (Multiple recipients separated by ,; enclosed in "") Example:/t "abc@163.com,123@56.com"
echo (Text file format for recipients is as follows:)
echo a@163.com
echo b@163.com
echo c@163.com
echo /s * Subject
echo /c Content:(Text/text file path with written content)
echo /ch HTML format switch for email content, indicating that the sent content is in HTML format
echo /a Attachment:(Absolute/relative path, multiple attachments separated by → enclosed in "") Example:/a "c:\a b.cmd→1234.txt"
goto :eof

:authentication_method1
>>"%temp%\%t_%" echo helo vkill
>>"%temp%\%t_%" echo auth login
for %%? in (%user%;%pass%) do (
set/p=%%?^<nul|base64>"l!t_!"
set/p v=<"l!t_!"
>>"%temp%\%t_%" echo !v!
del /f/q "l!t_!"
)
goto :eof

:del_
del /f/q "%temp%\%t_%">nul 2>nul
del /f/q "%temp%\l%t_%">nul 2>nul
del /f/q "%temp%\p-mailsend.log">nul 2>nul
goto :eof

:htmlortxt
if "%ch%"=="on" (>>"%temp%\%t_%" echo Content-Type: text/html;) else (>>"%temp%\%t_%" echo Content-Type: text/plain;)
goto :eof

:compress_and_encode_attachment
if "%~1"=="" exit/b
if "%~x1"==".rar" (copy "%~1" "%temp%\%~n1_.rar" >nul 2>nul) else (
dir %~1 >nul 2>nul &&(rar.exe -r a "%temp%\%~n1_.rar" "%~1" >nul 2>nul)||(rar.exe a "%temp%\%~n1_.rar" "%~1" >nul 2>nul)
)
if not exist "%temp%\%~n1_.rar" (set xx=vkill&exit/b)
for %%? in ("%temp%\%~n1_.rar") do (set/a z=z+%%~z?)
>>"%temp%\%t_%" echo --=====vkill=====
>>"%temp%\%t_%" echo Content-Type: application/octet-stream;
>>"%temp%\%t_%" echo name="%~n1_.rar"
>>"%temp%\%t_%" echo Content-Transfer-Encoding: base64
>>"%temp%\%t_%" echo Content-Disposition: attachment;
>>"%temp%\%t_%" echo filename="%~n1_.rar"
>>"%temp%\%t_%" echo.
base64.exe -i "%temp%\%~n1_.rar">>"%temp%\%t_%"
>>"%temp%\%t_%" echo.
del /f/q "%temp%\%~n1_.rar" >nul 2>nul
goto :eof

:sleep_
call :del_
ping -n 2 127.1 >nul 2>nul
goto :eof

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

=Hiddenpass.cmd_s=
@echo off
chcp 437>nul&graftabl 936>nul
echo hP1X500Pf3/f1/5++u5x>in.com
echo (Note: Password is not displayed in plain text when entered)
set /p password=Please enter the password for mail:%~1:<nul
for /f "tokens=*" %%i in ('in.com') do set password=%%i
del in.com
echo.
>%temp%\pass set password
exit
=Hiddenpass.cmd_e=

:::::::::::::::::::::Currently supported addresses::::::::::::::::::::::
::,Mailbox address,smtp address,telnet smtp port,authentication method,maximum attachment size (k)
::,21cn.com,smtp.21cn.com,25,1,15000000
::,sina.com,smtp.sina.com.cn,25,1,15000000
::,163.com,smtp.163.com,25,1,20000000
::,126.com,smtp.126.com,25,1,20000000
::,sohu.com,smtp.sohu.com,25,1,10000000
::,yahoo.com.cn,smtp.mail.yahoo.com,25,1,15000000
::,yahoo.com,smtp.mail.yahoo.com,25,1,15000000
::,qq.com,smtp.qq.com,25,1,5000000
::



[ Last edited by vkill on 2007-11-18 at 05:46 PM ]
Recent Ratings for This Post ( 6 in total) Click for details
RaterScoreTime
everest79 +15 2007-04-21 04:32
bjsh +12 2007-04-25 09:19
lxmxn +20 2007-04-25 09:25
flyinspace +8 2007-04-25 10:21
vlq5299 +2 2007-05-06 00:56
516526966 +1 2009-06-21 05:08
Attachments
p-mailsend v3.8.rar (3.16 KiB, Credits to download 1 pts, Downloads: 375)
p-mailsend_v4.0(all.rar (190.21 KiB, Downloads: 1009)
Floor 3 Posted 2007-04-21 04:34 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
This is good, can be mass - sent.
Floor 4 Posted 2007-04-21 04:35 ·  中国 甘肃 张掖 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Originally posted by everest79 at 2007-4-21 04:34:
This is good, can mass-send.

Haha, I knew you'd think about this aspect. There are many mass-sending tools online, and I believe those are much more efficient.
Floor 5 Posted 2007-04-21 04:38 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
Okay, this one is refuted by you, but there's another one, which is the attachment size, heh, didn't expect it, right?
Floor 6 Posted 2007-04-21 04:39 ·  中国 甘肃 张掖 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Originally posted by everest79 at 2007-4-21 04:38:
Okay, this one is refuted by you, but there is another one, which is the attachment size, heh, didn't expect it?

I tried this, it seems that the maximum supported attachment is 1M
Floor 7 Posted 2007-04-21 04:42 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
This person is daydreaming, I thought it would skip the link size limitation link that part.
Floor 8 Posted 2007-04-21 08:18 ·  中国 四川 成都 联通
中级用户
★★
Credits 346
Posts 103
Joined 2004-04-06 00:00
22-year member
UID 21852
Gender Male
Status Offline
Not bad, bump
Floor 9 Posted 2007-04-21 10:04 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
Down with sockpuppets
Floor 10 Posted 2007-04-25 09:10 ·  中国 甘肃 张掖 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Updated...
Floor 11 Posted 2007-04-25 09:21 ·  中国 浙江 杭州 电信
银牌会员
★★★
Credits 2,000
Posts 621
Joined 2007-01-01 00:00
19-year member
UID 75212
Gender Male
Status Offline
Brother vkill has released a good thing again;

Add points, download, go back and study
Floor 12 Posted 2007-04-25 09:26 ·  中国 甘肃 张掖 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Originally posted by bjsh at 2007-4-25 09:21:
Brother vkill has released another great thing;

Add points Download Go back and study

Hehe, help me test it carefully~ Hope we can improve it together
Floor 13 Posted 2007-04-25 09:28 ·  中国 甘肃 张掖 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Found an error. Interactive mode. When this parameter is used, all other parameters are invalid. I took another look at the code and used /x, and other parameters are still valid. Hehe
Floor 14 Posted 2007-04-25 09:40 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Not bad, add points to support.

In addition, there is a small suggestion. After a login failure, many temporary files are generated. It is recommended to add a function to automatically delete these temporary files after a login failure.
Floor 15 Posted 2007-04-25 09:42 ·  中国 甘肃 张掖 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Originally posted by lxmxn at 2007-4-25 09:40:
Not bad, add points to support.

In addition, there is a small suggestion. After a login failure, many temporary files are generated. It is suggested to add a function to automatically delete these temporary files after a login failure.

Hehe, you can modify it yourself and make do with it first. When I update to 3.0 later, I believe it will be very perfect.

When an error occurs, just add call :del_.
Recent Ratings for This Post ( 2 in total) Click for details
RaterScoreTime
+1 2009-03-04 06:10
+1 2010-02-18 18:55
1 2 3 9 Next ›
Forum Jump: