通过CMD控制台发送邮件

use*_*273 12 email console cmd smtp sendmail

嗨我想通过microsoft cmd控制台发送邮件.我尝试了很多方式,但我没有成功.

我试过这篇文章http://jpsoft.com/help/index.htm?sendmail.htm

sendmail "bob@bob.com bcc:joe@joe.com" Test Hello!
Run Code Online (Sandbox Code Playgroud)

错误是:

'sendmail' is not recognized as an internal or external command operable program or batch file
Run Code Online (Sandbox Code Playgroud)

本文:http://www.brighthub.com/office/collaboration/articles/21840.aspx#imgn_1

c:\>"c:\program files\microsoft office\office12\outlook.exe" /c ipm.note /m someone@gmail.com /a "c:\logs\logfile.txt"
Run Code Online (Sandbox Code Playgroud)

错误是:

the process can not access the file because it is being used by another proccess
Run Code Online (Sandbox Code Playgroud)

但它没有奏效.我不知道问题出在哪里或者问题是什么.

谢谢你的建议.

Mah*_*EFE 22

场景: 您的域名:mydomain.com 您希望发送给的域名:theirdomain.com

1.确定要发送到的邮件服务器. 打开CMD提示符键入

NSLOOKUP 
 set q=mx 
 theirdomain.com
Run Code Online (Sandbox Code Playgroud)

响应:

Non-authoritative answer: 
theirdomain.com MX preference = 50, mail exchanger = mail.theirdomain.com 
Nslookup_big
Run Code Online (Sandbox Code Playgroud)

编辑 确保键入exit以终止NSLOOKUP.

2.连接到他们的邮件服务器

SMTP通过端口25进行通信.我们现在尝试使用TELNET连接到他们的邮件服务器 "mail.theirdomain.com"

打开CMD提示

TELNET MAIL.THEIRDOMAIN.COM 25
Run Code Online (Sandbox Code Playgroud)

您应该看到这样的回复:

220 mx.google.com ESMTP 6si6253627yxg.6
Run Code Online (Sandbox Code Playgroud)

请注意,不同的服务器会提出不同的问候,但你应该得到SOMETHING.如果此时没有任何问题,则有两个可能的问题.端口25在防火墙处被阻止,或者他们的服务器没有响应.尝试使用其他域名,如果有效,则不是您.

3.发送电子邮件

现在,使用简单的SMTP命令发送测试电子邮件.这非常重要,您不能使用退格键,它将在屏幕上工作但不能正确解释.您必须完美地键入这些命令.

ehlo mydomain.com 
mail from:<martin9700@mydomain.com> 
rcpt to:<recipient@theirdomain.com> 
data 
This is a test, please do not respond
. 
quit
Run Code Online (Sandbox Code Playgroud)

那么,这一切意味着什么呢? EHLO - 向您自己介绍邮件服务器也可以使用HELO,但EHLO告诉服务器使用扩展命令集(不是我们正在使用它).

MAIL FROM - 谁发送电子邮件.确保放置大于/小于括号,因为许多电子邮件服务器将需要此(Postini).

RCPT TO - 您要将其发送给谁.您需要再次使用括号.有关如何测试中继邮件的信息,请参阅步骤#4!

DATA - 告诉SMTP服务器以下内容是您电子邮件的正文.确保最后点击"Enter".

. - 单独的时间段告诉SMTP服务器您已完成数据部分,并且发送电子邮件很明显.

退出 - 退出TELNET会话.

4.测试SMTP中继 测试SMTP中继非常简单,只需要对上述命令进行少量更改即可.见下文:

ehlo mydomain.com 
mail from:<martin9700@mydomain.com> 
rcpt to:<recipient@someotherdomain.com> 
data 
This is a test, please do not respond 
. 
quit
Run Code Online (Sandbox Code Playgroud)

看到不同?在RCPT TO行,我们将发送到不受我们发送的SMTP服务器控制的域.SMTP中继已关闭,您将立即收到错误消息.如果您能够继续并发送电子邮件,则该服务器允许中继.


Ans*_*ers 6

除非您想直接通过telnet您的 SMTP 服务器与您交谈,否则您将使用命令行邮件程序,例如blat

blat -to you@example.com -f me@example.net -s "mail subject" ^
  -server smtp.example.net -body "message text"
Run Code Online (Sandbox Code Playgroud)

bmail

bmail -s smtp.example.net -t you@example.com -f me@example.net -h ^
  -a "mail subject" -b "message text"
Run Code Online (Sandbox Code Playgroud)

您还可以使用VBScriptPowerShell编写自己的邮件程序。