Email 通过CMD控制台发送邮件

Email 通过CMD控制台发送邮件,email,console,cmd,smtp,sendmail,Email,Console,Cmd,Smtp,Sendmail,您好,我想通过microsoft cmd控制台发送邮件。我尝试了很多方法,但没有成功 我试过这篇文章 错误是: 'sendmail' is not recognized as an internal or external command operable program or batch file 及 本文: 错误是: the process can not access the file because it is being used by another proccess 但它不起作

您好,我想通过microsoft cmd控制台发送邮件。我尝试了很多方法,但没有成功

我试过这篇文章

错误是:

'sendmail' is not recognized as an internal or external command operable program or batch file

本文:

错误是:

the process can not access the file because it is being used by another proccess
但它不起作用。我不知道哪里出了问题,或者出了什么问题

感谢您的建议。

场景: 您的域名:
mydomain.com
要发送到的域:
theirdomain.com

1。确定要发送到的邮件服务器。 打开CMD提示符 类型

答复:

编辑 确保键入exit终止NSLOOKUP

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

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

打开CMD提示符

TELNET MAIL.THEIRDOMAIN.COM 25
你应该看到这样的回应:

220 mx.google.com ESMTP 6si6253627yxg.6
请注意,不同的服务器将提供不同的问候语,但您应该得到一些东西。如果此时未出现任何问题,则可能存在两个问题。端口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
ehlo mydomain.com
邮寄地址:
rcpt至:
资料
这是一个测试,请不要回应
. 
退出
那么,这一切意味着什么? EHLO-向邮件服务器自我介绍HELO也可以使用,但EHLO告诉服务器使用扩展命令集(不是我们正在使用它)

邮件发件人-谁在发送电子邮件。确保将其置于大于/小于括号内,因为许多电子邮件服务器都需要此括号(Postini)

RCPT收件人-您要将其发送给谁。同样,您需要使用括号。有关如何测试中继邮件,请参见第4步

数据-告诉SMTP服务器以下内容是您的电子邮件正文。确保在最后点击“回车”

.-行中的句点告诉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
ehlo mydomain.com
邮寄地址:
rcpt至:
资料
这是一个测试,请不要回应
. 
退出

看到区别了吗?在RCPT TO行中,我们发送到的域不受发送到的SMTP服务器控制。如果SMTP中继关闭,您将立即收到一个错误。如果您能够继续发送电子邮件,则该服务器允许中继。

除非您想通过
telnet直接与SMTP服务器通话,否则您可以使用命令行邮件程序,如:

或:


您也可以在或中编写自己的邮件程序。

在Linux上,您可以使用“swaks”,它是许多发行版的官方软件包,包括EPEL上的Debian/Ubuntu和Redhat/CentOS:

swaks -f you@example.net -t someone@example.com \
    --server mail.example.com

还有几个命令行邮件程序:


两者都支持SSL。

根据我的经验,BLAT功能更强大,但很难在所有Windows版本上运行。BMAIL正常工作。Linux如何帮助他从Windows发送邮件?@access\u授予WSL:Windows Linux子系统
220 mx.google.com ESMTP 6si6253627yxg.6
ehlo mydomain.com 
mail from:<martin9700@mydomain.com> 
rcpt to:<recipient@theirdomain.com> 
data 
This is a test, please do not respond
. 
quit
ehlo mydomain.com 
mail from:<martin9700@mydomain.com> 
rcpt to:<recipient@someotherdomain.com> 
data 
This is a test, please do not respond 
. 
quit
blat -to you@example.com -f me@example.net -s "mail subject" ^
  -server smtp.example.net -body "message text"
bmail -s smtp.example.net -t you@example.com -f me@example.net -h ^
  -a "mail subject" -b "message text"
swaks -f you@example.net -t someone@example.com \
    --server mail.example.com