Send mail through the CMD console

Hi, I want to send mail through the microsoft cmd console. I tried a lot, but I could not.

I tried this article http://jpsoft.com/help/index.htm?sendmail.htm

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

mistake:

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

and

in this article: 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" 

mistake:

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

but it didn’t work. I don’t know where the problem is or what the problem is.

Thanks for your advice.

+9
cmd email console smtp sendmail
source share
4 answers

Scenario: your domain: mydomain.com domain you want to send: theirdomain.com

1. Identify the mail server to which you are sending. Open prompt CMD Type

 NSLOOKUP set q=mx theirdomain.com 

Response:

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

EDIT Be sure to enter exit to complete NSLOOKUP.

2. Connect to your mail server

SMTP communicates on port 25. Now we will try to use TELNET to connect to our mail server "mail.theirdomain.com"

Open the CMD prompt

 TELNET MAIL.THEIRDOMAIN.COM 25 

You should see something like this as an answer:

 220 mx.google.com ESMTP 6si6253627yxg.6 

Keep in mind that different servers will have different greetings, but you should get SOMETHING. If nothing arises at this moment, there are two possible problems. Port 25 is blocked on your firewall, or their server is not responding. Try a different domain, if it works, then it's not you.

3. Send an email

Now use simple SMTP commands to send a test message. This is very important, you CANNOT use the backspace key, it will work on the screen, but will not be interpreted correctly. You must type these commands perfectly.

 ehlo mydomain.com mail from:< martin9700@mydomain.com > rcpt to:< recipient@theirdomain.com > data This is a test, please do not respond . quit 

So what does this mean? EHLO - introduce yourself on the HELO mail server; you can also use it, but EHLO tells the server to use an extended set of commands (and not the one we use).

MAIL FROM - who sends the email. Make sure that it is larger or smaller than in brackets, as this will require many email servers (Postini).

RCPT TO - who you send it to. Again you need to use parentheses. See Step # 4 on how to check mail relay!

DATA - tells the SMTP server that the following is the body of your message. Remember to press "Enter" at the end.

- only the period in the line tells the SMTP server that you did everything with a piece of data, and it is clear to send an email.

quit - ends a TELNET session.

4. Testing the SMTP relay Testing the SMTP relay is very simple and just requires a slight modification to the above commands. See below:

 ehlo mydomain.com mail from:< martin9700@mydomain.com > rcpt to:< recipient@someotherdomain.com > data This is a test, please do not respond . quit 

See the difference? In the RCPT TO line, we send a domain that is not controlled by the SMTP server to which we are sending. You will get an immediate error: SMTP relay is off. If you can continue and send an email, then relay is allowed by this server.

+21
source share

If you do not want to communicate directly with the SMTP server via telnet , you should use command-line mail programs such as blat :

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

or bmail :

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

You can also write your own mailer in VBScript or PowerShell .

+4
source share

From Linux, you can use "swaks", which is available as an official package on many distributions, including Debian / Ubuntu and Redhat / CentOS on EPEL:

 swaks -f you@example.net -t someone@example.com \ --server mail.example.com 
+1
source share

A few more e-mail programs on the command line:

Both support SSL too.

0
source share

All Articles