【问题标题】:Send mail via CMD console通过 CMD 控制台发送邮件
【发布时间】:2013-09-10 05:06:53
【问题描述】:

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

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

sendmail "bob@bob.com bcc:joe@joe.com" Test Hello!

错误是:

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

这篇文章: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"

错误是:

the process can not access the file because it is being used by another proccess

但它没有工作。我不知道问题出在哪里或什么问题。

感谢您的建议。

【问题讨论】:

    标签: email console cmd smtp sendmail


    【解决方案1】:

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

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

    NSLOOKUP 
     set q=mx 
     theirdomain.com
    

    回应:

    Non-authoritative answer: 
    theirdomain.com MX preference = 50, mail exchanger = mail.theirdomain.com 
    Nslookup_big
    

    编辑 请务必键入 exit 以终止 NSLOOKUP。

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

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

    打开一个 CMD 提示符

    TELNET MAIL.THEIRDOMAIN.COM 25
    

    您应该会看到类似这样的响应:

    220 mx.google.com ESMTP 6si6253627yxg.6
    

    请注意,不同的服务器会提出不同的问候,但您应该得到一些东西。如果此时没有出现任何问题,则可能有 2 个问题。防火墙阻止了端口 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 - 向邮件服务器介绍自己 HELO 也可以使用,但 EHLO 告诉服务器使用扩展命令集(不是我们正在使用的)。

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

    RCPT TO - 您将其发送给谁。同样,您需要使用括号。请参阅第 4 步,了解如何测试中继邮件!

    DATA - 告诉 SMTP 服务器接下来是您的电子邮件正文。确保最后按“Enter”。

    。 - 一行中的句号告诉 SMTP 服务器你已经完成了数据部分,可以清楚地发送电子邮件了。

    quit - 退出 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
    

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

    【讨论】:

      【解决方案2】:

      除非您想通过telnet 直接与 SMTP 服务器通信,否则您将使用像blat 这样的命令行邮件:

      blat -to you@example.com -f me@example.net -s "mail subject" ^
        -server smtp.example.net -body "message text"
      

      bmail:

      bmail -s smtp.example.net -t you@example.com -f me@example.net -h ^
        -a "mail subject" -b "message text"
      

      您也可以在VBScriptPowerShell 中编写自己的邮件。

      【讨论】:

      • 根据我的经验,BLAT 功能更强大,但很难在所有 Windows 版本上运行。 BMAIL 可以正常工作。
      【解决方案3】:

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

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

      【讨论】:

      • Linux 如何帮助他从 Windows 发送它?
      • @access_granted WSL:适用于 Linux 的 Windows 子系统
      【解决方案4】:

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

      两者都支持 SSL。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-01-23
        • 2011-03-27
        • 2014-10-08
        • 1970-01-01
        • 2013-11-06
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多