标题: [网络工具] 收发邮件之命令行工具GetMail与blat [打印本页]
作者: cjiabing 时间: 2012-5-20 20:24 标题: 收发邮件之命令行工具GetMail与blat
——GetMail与Blat是一对伴侣,GetMail负责接收邮件,Blat负责发送邮件,两者都是在命令行下使用,同样适合批处理调用,特地推荐给大家,一楼介绍GetMail,二楼介绍Blat。
——GetMail相对简单些,已将GetMail都翻译过来了,当然,还是有些需要核实的,欢迎各位指点!~
GetMail v1.33: WinNT console utility to download a mailbox's mail.
GetMail v1.33: 一个可以从邮箱下载邮件的实用程序。
syntax:
语法参数:
Getmail -u <user> -pw <password> -s <server> [optional switches (see below)]
Getmail -install [ see install details below ]
Getmail -profile [-delete | "<default>"] [profile1] [profileN] [-q]
Getmail -h [-q]
Getmail -forceextract filename
-install <server> <userid> <password> [<delete> [<xtract> [<try> [<port> [<profile>]]]]]
-install <服务器> <用户名> <密 码> [<删除> [< 电路> [<尝试>[<端口> [ <文件> ]]]]]
: set's POP3 server, login, password, whether to delete or not (Yes/No),
:设置的POP 3服务器,登录,密码,及是否删除或不(是/否),
whether to automatically extract base64/7bit/UU encoded files or not (Yes/No),
是否自动提取Base 64/7位/支原体编码的文件或不(是的/没有),
number of tries and port for profile
尝试的次数和端口介绍
(<delete> <xtract> <try> and <port> may be replaced by '-').
(<删除> <电路> <尝试>和 <端口> 可能用 '- ' 取代)。
——这几行话比较难理解,大家从后面解释读起!~
-u <userid> : Specify userid on remote pop3 host
:邮箱账号
-pw <password>: Specify password for userid on remote mail host
:邮箱密码
-s <server> : Specify mail server (pop3) to contact
:邮箱服务器,默认pop3。
-nodelete : Do not delete messages after downloading (default)
:下载后不删除邮箱里的邮件,默认不删除
-delete : Delete messages after downloading
:下载后从邮箱里删除下载过的邮件——试过了,不懂的慎用!~
-noxtract : Do not extract base64/7bit/UU files after downloading (default)
:默认不下载附件,下载结束后不提取的 base64/7bit/UU 文件——比较难理解,参考neorobin的介绍:-xtract 参数来提取附件.
-xtract [defname]: Extract base64/7bit/UU encoded files after downloading messages
:下载附件——同上,xtract,难以找到该词,自动翻译为电路,extract翻译为提取,而tract翻译为束、带子
defname is an optional default filename for the extracted file
一个可选的默认文件名为提取的文件——如果不理解上面的参数,这个一样莫名其妙
-domainstamp : Prepend sender's domain name to extracted attachments
:添加发件人的域名提取附件——欢迎试验
-headersonly : Download only the headers of the message
:下载邮件头部信息
-port <port> : port to be used on the server, defaults to POP3 (110)
:指定端口,默认是pop3的110
-p <profile> : send with SMTP server, user and port defined in <profile>.
:发送的SMTP服务器,用户和端口定义在<文件>。——同样难以理解,profile,有的翻译为:轮廓、侧面、外形;简介
参考neorobin的介绍:-p 是用来指定获取参数的配置的(当然前提是之前有保存好的配置).
-q : supresses *all* output.
:所谓的安静模式
-n <n> : Only get 'n' messages
:总共获取 N 封邮件(从最新一封邮件开始往下/后数)
-m <n> : Only get message # n
:仅仅获取第 N 封邮件(获取指定序号的邮件,从最早一封邮件开始往上/前数)
-b <n> : Retrieve messages beginning from # n
:从第 N 封邮件开始下载多个邮件(从指定数字开始提取最近/新的邮件)
-plain : Extract text/plain segments too (usually ignored)
:提取纯文本段,通常忽略,也就是默认就是txt文件
-h : displays this help.
:显示帮助信息
-try <n times>: how many attempts to access mail. from '1' to 'INFINITE'
:试访问服务器上的邮件的次数,从 ‘1’ 到无限
-ti <n> : Set timeout to 'n' seconds.
:设置超时时间-秒
-forceextract fn: Attempt to extract any encoded messages in 'fn'
:尝试使用强制模式提取任何编码信息——没试过
使用示例:
getmail -u bathome@163.com -pw 123456 -s pop.163.com
默认下载标记为未读的邮件,下载到getmail所在目录,邮件名称一般为MSG01等。
其他:
如果有必要,把gwinsock.dll和getmail.exe一起拷到 c:\windows\system32
第一次下载全部邮件,第二次下载未读邮件,下载的邮件一般保存在getmail所在目录。
参考:
http://www.bathome.net/thread-7465-1-1.html
很少见到getmail的使用和说明,批处理之家为您推荐好作品!~
谢谢 hmgl 的推荐和 neorobin的解释,他们为getmail和blat在中国的传播做了贡献!~
Blat与getmail最新应用版201205.rar
http://pan.baidu.com/share/link?shareid=3823300890&uk=1124163200
作者: cjiabing 时间: 2012-5-20 23:16 标题: 发送邮件之blat
本帖最后由 cjiabing 于 2012-11-18 23:39 编辑
发送邮件之blat,我是先知道有blat才知道有getmail的,同getmail一样,以前网上blat的中文介绍也很少,最近用的人多了,做个全面翻译很有必要。
下了个最新版的,参数真多,翻译麻烦了!~
在后面提供一个简单的使用示例,具体的参数用到了再翻译吧!
Blat v3.0.3 (build : May 15 2012 01:53:41)
32-bit Windows, Full, Unicode
Windows console utility to send mail via SMTP or post to usenet via NNTP
by P.Mendes,M.Neal,G.Vollant,T.Charron,T.Musson,H.Pesonen,A.Donchey,C.Hyde
http://www.blat.net
syntax:
Blat <filename> -to <recipient> [optional switches (see below)]
Blat -SaveSettings -f <sender email addy> -server <server addr>
[-port <port>] [-try <try>] [-profile <profile>]
[-u <login id>] [-pw <password>]
or
Blat -install <server addr> <sender's addr> [<try>[<port>[<profile>]]] [-q]
Blat -profile [-delete | "<default>"] [profile1] [profileN] [-q]
Blat -h
-------------------------------- Installation ---------------------------------
-SaveSettings : store common settings to the Windows Registry. Takes the
same parameters as -install, and is only for SMTP settings.
-install[SMTP|NNTP|POP3|IMAP] <server addr> <sender email addr> [<try n times>
[<port> [<profile> [<username> [<password>]]]]]
: set server, sender, number of tries and port for profile
(<try n times> and <port> may be replaced by '-')
port defaults are SMTP=25, NNTP=119, POP3=110, IMAP=143
default profile can be specified with a '-'
username and/or password may be stored to the registry
order of options is specific
use -installNNTP for storing NNTP information
use -installPOP3 for storing POP3 information
(sender and try are ignored, use '-' in place of these)
use -installIMAP for storing IMAP information
(sender and try are ignored, use '-' in place of these)
--------------------------------- The Basics ----------------------------------
<filename> : file with the message body to be sent
if your message body is on the command line, use a hyphen (-)
as your first argument, and -body followed by your message
if your message will come from the console/keyboard, use the
hyphen as your first argument, but do not use -body option.
-of <file> : text file containing more options (also -optionfile)
-to <recipient> : recipient list (also -t) (comma separated)
-tf <file> : recipient list filename
-cc <recipient> : carbon copy recipient list (also -c) (comma separated)
-cf <file> : cc recipient list filename
-bcc <recipient>: blind carbon copy recipient list (also -b)
(comma separated)
-bf <file> : bcc recipient list filename
-maxNames <x> : send to groups of <x> number of recipients
-ur : set To: header to Undisclosed Recipients if not using the
-to and -cc options
-subject <subj> : subject line, surround with quotes to include spaces(also -s)
-ss : suppress subject line if not defined
-sf <file> : file containing subject line
-bodyF <file> : file containing the message body
-body <text> : message body, surround with quotes (") to include spaces
-sig <file> : text file containing your email signature
-tag <file> : text file containing taglines, to be randomly chosen
-ps <file> : final message text, possibly for unsubscribe instructions
----------------------------- Registry overrides ------------------------------
-p <profile> : send with server, user, and port defined in <profile>
: use username and password if defined in <profile>
-profile : list all profiles in the Registry
-server <addr> : specify SMTP server to be used (optionally, addr:port)
-serverSMTP <addr>
: same as -server
-serverNNTP <addr>
: specify NNTP server to be used (optionally, addr:port)
-serverPOP3 <addr>
: specify POP3 server to be used (optionally, addr:port)
when POP3 access is required before sending email
-serverIMAP <addr>
: specify IMAP server to be used (optionally, addr:port)
when IMAP access is required before sending email
-f <sender> : override the default sender address (must be known to server)
-i <addr> : a 'From:' address, not necessarily known to the server
-port <port> : port to be used on the SMTP server, defaults to SMTP (25)
-portSMTP <port>: same as -port
-portNNTP <port>: port to be used on the NNTP server, defaults to NNTP (119)
-portPOP3 <port>: port to be used on the POP3 server, defaults to POP3 (110)
-portIMAP <port>: port to be used on the IMAP server, defaults to IMAP (110)
-u <username> : username for AUTH LOGIN (use with -pw)
or for AUTH GSSAPI with -k
-pw <password> : password for AUTH LOGIN (use with -u)
-pu <username> : username for POP3 LOGIN (use with -ppw)
-ppw <password> : password for POP3 LOGIN (use with -pu)
-iu <username> : username for IMAP LOGIN (use with -ppw)
-ipw <password> : password for IMAP LOGIN (use with -pu)
-k UNKNOWN mutual authentication and AUTH GSSAPI
-kc UNKNOWN client-only authentication and AUTH GSSAPI
-service <name> : Set GSSAPI service name (use with -k), default "smtp@server"
-level <lev> : Set GSSAPI protection level to <lev>, which should be one of
: None, Integrity, or Privacy (default GSSAPI level is Privacy)
-nomd5 : Do NOT use CRAM-MD5 authentication. Use this in cases where
the server's CRAM-MD5 is broken, such as Network Solutions.
---------------------- Miscellaneous RFC header switches ----------------------
-organization <organization>
: Organization field (also -o and -org)
-ua : include User-Agent header line instead of X-Mailer
-x <X-Header: detail>
: custom 'X-' header. eg: -x "X-INFO: Blat is Great!"
-noh : prevent X-Mailer/User-Agent header from showing Blat homepage
-noh2 : prevent X-Mailer header entirely
-d : request disposition notification
-r : request return receipt
-charset <cs> : user defined charset. The default is iso-8859-1
-a1 <header> : add custom header line at the end of the regular headers
-a2 <header> : same as -a1, for a second custom header line
-dsn <nsfd> : use Delivery Status Notifications (RFC 3461)
n = never, s = successful, f = failure, d = delayed
can be used together, however N takes precedence
-hdrencb : use base64 for encoding headers, if necessary
-hdrencq : use quoted-printable for encoding headers, if necessary
-priority <pr> : set message priority 0 for low, 1 for high
-sensitivity <s>: set message sensitivity 0 for personal, 1 for private,
2 for company-confidential
----------------------- Attachment and encoding options -----------------------
-attach <file> : attach binary file(s) to message (filenames comma separated)
-attacht <file> : attach text file(s) to message (filenames comma separated)
-attachi <file> : attach text file(s) as INLINE (filenames comma separated)
-embed <file> : embed file(s) in HTML. Object tag in HTML must specify
content-id using cid: tag. eg: <img src="cid:image.jpg">
-af <file> : file containing list of binary file(s) to attach (comma
separated)
-atf <file> : file containing list of text file(s) to attach (comma
separated)
-aef <file> : file containing list of embed file(s) to attach (comma
separated)
-base64 : send binary files using base64 (binary MIME)
-uuencode : send binary files UUEncoded
-enriched : send an enriched text message (Content-Type=text/enriched)
-unicode : message body is in 16- or 32-bit Unicode format
-html : send an HTML message (Content-Type=text/html)
-alttext <text> : plain text for use as alternate text
-alttextf <file>: plain text file for use as alternate text
-mime : MIME Quoted-Printable Content-Transfer-Encoding
-8bitmime : ask for 8bit data support when sending MIME
-multipart <size>
: send multipart messages, breaking attachments on <size>
KB boundaries, where <size> is per 1000 bytes
-nomps : do not allow multipart messages
-contentType <string>
: use <string> in the ContentType header for attachments that
do not have a registered content type for the extension
For example: -contenttype "text/calendar"
---------------------------- NNTP specific options ----------------------------
-groups <usenet groups>
: list of newsgroups (comma separated)
-------------------------------- Other options --------------------------------
-xtndxmit : Attempt to use POP3 to transmit when accessing POP3 first
-h : displays this help (also -?, /?, -help or /help)
-q : suppresses all output to the screen
-debug : echoes server communications to a log file or screen
(overrides -q if echoes to the screen)
-log <file> : log everything but usage to <file>
-timestamp : when -log is used, a timestamp is added to each log line
-overwritelog : when -log is used, overwrite the log file
-ti <n> : set timeout to 'n' seconds. Blat will wait 'n' seconds for
server responses
-try <n times> : how many times blat should try to send (1 to 'INFINITE')
-binary : do not convert ASCII | (pipe, 0x7c) to CrLf in the message
body
-hostname <hst> : select the hostname used to send the message via SMTP
this is typically your local machine name
-raw : do not add CR/LF after headers
-delay <x> : wait x seconds between messages being sent when used with
-maxnames or -multipart
-comment <char> : use this character to mark the start of comments in
options files and recipient list files. The default is ;
-superdebug : hex/ascii dump the data between Blat and the server
-superdebugT : ascii dump the data between Blat and the server
-------------------------------------------------------------------------------
Note that if the '-i' option is used, <sender> is included in 'Reply-to:'
and 'Sender:' fields in the header of the message.
Optionally, the following options can be used instead of the -f and -i
options:
-mailfrom <addr> The RFC 821 MAIL From: statement
-from <addr> The RFC 822 From: statement
-replyto <addr> The RFC 822 Reply-To: statement
-returnpath <addr> The RFC 822 Return-Path: statement
-sender <addr> The RFC 822 Sender: statement
For backward consistency, the -f and -i options have precedence over these
RFC 822 defined options. If both -f and -i options are omitted then the
RFC 821 MAIL FROM statement will be defaulted to use the installation-defined
default sender address.
使用示例:
blat发送邮件举例:
- @echo off
- blat -install smtp.qq.com 123123123@qq.com
- blat C:\blat\body.txt -to 456456456@qq.com -u 123123123@qq.com -pw 123456 -subject 我爱你 -attach C:\blat\attach.txt
- pause
复制代码
123123123@qq.com ——发送邮箱;
456456456@qq.com ——接收邮箱;
-pw 123456 ——发送邮箱密码,可用base64编码,还没试过;
-subject 我爱你 ——邮件标题;
-attach C:\blat\attach.txt ——附件,把内容保存到attach文档内;
C:\blat\body.txt ——邮件正文,用body.txt保存在程序下。
smtp.qq.com ——邮箱服务地址。
参考:
http://www.bathome.net/thread-4839-1-1.html
作者: cjiabing 时间: 2012-5-20 23:20
占位编辑
作者: pdanniel66 时间: 2012-5-23 06:58
標題的 balt 應為 ==> blat
作者: jwm112377 时间: 2012-9-7 18:27
好好学习一下,真是好东西啊!
作者: lengyff 时间: 2013-1-25 14:10
若用blat接收到有乱码的邮件,可在末尾加上 -charset gbk
作者: yanshouke 时间: 2013-8-15 16:41
-n 3 是从第一封邮件到第3封的获取,并不是从最新的超下面取3个
作者: 522235677 时间: 2016-2-12 15:55
回复 7# yanshouke
是的,-m -n 都是一样的效果。好像没办法直接获取最新的邮件
作者: k1314521jx 时间: 2016-2-21 14:18
回复 8# 522235677
blat 现在不能用了吧!!你能用blat成功发送邮件???
作者: 522235677 时间: 2016-2-23 12:45
回复 9# k1314521jx
我不用这个发送邮件,我想用来接受邮件的
作者: k1314521jx 时间: 2016-2-23 13:13
回复 10# 522235677
那请问,你发邮件是用什么呢?求教
作者: 522235677 时间: 2016-2-23 14:42
回复 11# k1314521jx
我都用vbs
作者: dimo 时间: 2022-12-12 20:55
本帖最后由 dimo 于 2022-12-12 21:07 编辑
发现一个getmail解释中比较大的错误。
-xtract参数。解释中“base64/7bit/UU”这几个词一直很乍眼,不像是能够下载邮件的附件。
经过我的测试,发现这个参数是用来解码邮件内容明文的。getmail下载的MSG*.TXT中邮件明文部分是加密的,同时上面一行提到了加密方法(我测试时得到的是base64)则message文件中有这样一行:- Content-Transfer-Encoding: base64
复制代码
同时下面的内容为:- PGRpdiBkaXI9ImF1dG8iPmNvbnRleHQ8L2Rpdj4=
复制代码
此时若不加-xtract参数,则直接留下MSG*.TXT这一个文件,程序退出。而如果加上此参数,getmail还会对上面的base64编码进行解码,输出到extract*.out文件,将其后缀名改为txt即可打开,得到邮件原文:- <div dir="auto">context</div>
复制代码
此时defname参数的意义也可得到解释。即可以选择将解码的内容输出到一个给定的文件名。
同时也可解释-domainstamp参数,即在上述提取出解码文本的文件基础上,再带一个“带有发件人地址的邮戳”,也就是把from信息也输出到解码的文件内。(未尝试)
不过这个-xtract参数同时也能用于下载附件。也就是说它具有多种用途。
总结一下就是,-xtract参数可以用于下载附件,同时也可以用于解码邮件明文(不知道是不是多嘴)
作者: lancer 时间: 2023-8-16 19:36
发现邮件主题是乱码,不知道怎么解决。。邮件正文可以通过加-charset gbk解决乱码,但是主题不行。
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |