Send mail via CMD console - email

Hi i want to send mail via microsoft cmd console. I tried many way, but i didnt succeed.
i tried this article http://jpsoft.com/help/index.htm?sendmail.htm
sendmail "bob#bob.com bcc:joe#joe.com" Test Hello!
the error is :
'sendmail' is not recognized as an internal or external command operable program or batch file
and
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"
the error is :
the process can not access the file because it is being used by another proccess
but it didnt worked. i dont know where is the problem or what is the problem.
thanks for your advice.

Scenario:
Your domain: mydomain.com
Domain you wish to send to: theirdomain.com
1. Determine the mail server you're sending to.
Open a CMD prompt
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 type exit to terminate NSLOOKUP.
2. Connect to their mail server
SMTP communicates over port 25. We will now try to use TELNET to connect to their mail server "mail.theirdomain.com"
Open a CMD prompt
TELNET MAIL.THEIRDOMAIN.COM 25
You should see something like this as a response:
220 mx.google.com ESMTP 6si6253627yxg.6
Be aware that different servers will come up with different greetings but you should get SOMETHING. If nothing comes up at this point there are 2 possible problems. Port 25 is being blocked at your firewall, or their server is not responding. Try a different domain, if that works then it's not you.
3. Send an Email
Now, use simple SMTP commands to send a test email. This is very important, you CANNOT use the backspace key, it will work onscreen but not be interpreted correctly. You have to 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 that all mean?
EHLO - introduce yourself to the mail server HELO can also be used but EHLO tells the server to use the extended command set (not that we're using that).
MAIL FROM - who's sending the email. Make sure to place this is the greater than/less than brackets as many email servers will require this (Postini).
RCPT TO - who you're sending it to. Again you need to use the brackets. See Step #4 on how to test relaying mail!
DATA - tells the SMTP server that what follows is the body of your email. Make sure to hit "Enter" at the end.
. - the period alone on the line tells the SMTP server you're all done with the data portion and it's clear to send the email.
quit - exits the TELNET session.
4. Test SMTP relay
Testing SMTP relay is very easy, and simply requires a small change 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? On the RCPT TO line, we're sending to a domain that is not controlled by the SMTP server we're sending to. You will get an immediate error is SMTP relay is turned off. If you're able to continue and send an email, then relay is allowed by that server.

Unless you want to talk to an SMTP server directly via telnet you'd use commandline mailers like 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 could also write your own mailer in VBScript or PowerShell.

From Linux you can use 'swaks' which is available as an official packages on many distros including Debian/Ubuntu and Redhat/CentOS on EPEL:
swaks -f you#example.net -t someone#example.com \
--server mail.example.com

A couple more command-line mailer programs:
mailsend
Mail Alert Simple Mailer
Both support SSL too.

Related

SMTP: Remote client not responding to 220

Recently I've been experimenting with a simple script that listens on port 25, and receives and logs any incoming emails.
It's a very primitive script, and it doesn't implement the SMTP protocol at all. It just simply spits out canned replies, and it works something like this:
Wait for an incoming socket.
Send "220 example.com ESMTP Postfix".
Receive one line, typically like "EHLO other.com".
Send "250 example.com, I am pleased to meet you".
Receive lines until "DATA", reply with "250 Ok" every time".
Send "354 End data with .".
Receive lines until "." is received.
Send 250 Ok: queued as 12345.
Receive any final lines then close the socket.
(example.com is in place of my real domain's FQDN.)
It's a very crude script indeed; however, for the past few months it's worked perfectly for every email that I needed to receive. I can receive fine from Gmail, Protonmail, verification emails, etc. I also caught some internet-wide scans, so it serves as a fun honeypot too.
Today, I tried to receive a Microsoft account verification email to register a Microsoft account. The remote client didn't seem to respond to the 220 at all!
# nc -l -v -p 25
Listening on [0.0.0.0] (family 0, port 25)
Connection from mail-co1nam03on0003.outbound.protection.outlook.com 56725 received!
220 example.com ESMTP Postfix
No matter what I tried, the client wouldn't send anything. What am I doing wrong? Any ideas are welcome.
tripleee solved this in the comments, so I'm posting it as an answer here for everyone to see. The problem is that I was giving just LF as a newline, not CRLF. So I replaced all the '\n' with '\r\n' in my code, and that fixed it. I guess the other mailservers were just being lenient with me.

How to test smtp protocol's 250-PIPELINING function?

the smtp server support 250-PIPELINING function,so I can send many smtp command to server in one time
but I don't know how to test it?
I cann't find the 250-PIPELINING option on MUA (like outlook)
so I want to test it by telnet
I send two "rcpt to" command in one line,but server told me wrong:
so how can I test the 250-PIPELINING function?Thanks
You can't send 2 commands on the same line. The command syntax is the same for PIPELINED commands - the difference is that you can send multiple commands without having to wait for a response first.
The only way to test this via telnet is to first construct a text file with multiple commands and then copy & paste that into your telnet app.

how to receive mail commandline?

Can anybody suggest me a way to receive mail from commandline and save it to a file. i have tried some tool but those were of no use. i tried getmail and popclient. but every time i get an error. may be my syntax is wrong.
in getmail i tried this command
getmail -u myemail#gmail.com -pw password -s imap.gmail.com -port 110
and got error of winsock.dll
i have also tried it with port 993 and in this case it gave error of possible time out
and in popclient i also used this type of settings in config.xml but i got the same error of server not responding.can anybody figure out what's the problem?
The port number is wrong for gmail, and you need to use the POP access feature of gmail and the POP email server to connect to (not via imap).
Gmail uses a secure port and also SSL security. Enable the POP retrieval/access in Gmail configuration and read the Gmail help on how to access via POP (for any client) - it will list the port number and server name and security encryption.

Send email using Telnet

I found this article which explains sending email from telnet
http://www.kongtechnology.com/2008/01/27/smtp-authentication-and-send-emails-using-telnet/
but actually I have problem with it.
when i wrote this command
auth login
I got
Connection to host lost.
so, what is the problem?
http://www.ionfish.org/mxlookup
Type the URL of the site you want to find's mail server.
Open CMD, type:
telnet mx.sitedomain.com 25
then
HELO mx.sitedomain.com
next
MAIL FROM: president#whitehouse.gov
then
RCPT TO: secretary#whitehouse.gov
finally
SUBJECT: This message was brought to you in part by the moon.
Note: You need to send authentication requests, because most mail servers do not allow anonymous unsolicited mail to be sent. (spam).
http://technet.microsoft.com/en-us/library/aa995718%28v=exchg.65%29.aspx

How to send test email specifying SMTP server

I'd like to test to see if I can send email unauthenticated from an smtp server from my red hat box.
If I want to send a test email from command-line, I would do something like this:
mail -s Test addr#domain.com < /dev/null
How do I specify an SMTP server to send the mail through?
AFAIK you can't tell the built in 'mail' application which SMTP server to use - it simply uses sendmail on the local system.
You might want to grab the 'nail' rpm and use that instead, as then you can put 'set smtp=serveraddress' into /etc/mail.rc
You could try putting that in now, but it doesn't work on my CentOS 5.3 system.