Command send email windows command line

Not only is email very useful for communication between friends and families and sending messages with attachments such as reports, photos, documents,

Not only is email very useful for communication between friends and families and sending messages with attachments such as reports, photos, documents, presentations, video clips and music files, it’s also useful for notification purposes. For example, a website monitoring service such as Pingdom has alerts where you’ll be notified through different methods such as email, SMS, twitter or in-app when your server is down. Third party backup software also normally has at least an email notification feature where you can set it up to automatically email you when the backup process has completed or failed.

If you are writing a batch file and want to send an automated email when the batch has completed running or if you’re faced with a third party software that does not even support email notification, then the simple solution is to use a command line email sending tool for Windows. Here we have 7 ways to look at.

An example command line for sending an email using Gmail is given for every utility mentioned below. You’ll need to change the following information in the command line option:

  • sender@gmail.com = Replace it with your full Gmail address
  • recipient@email.com = Replace it with the email address that will receive the message
  • YourGmailPassword = Replace it with your Gmail password
  • subject = The subject of the email. Make sure it is enclosed with double quotes if there are spaces. For example, This is a long subject
  • body = The message of the email. Should also enclose with double quotes if there are spaces

1. SwithMail

Out of all the command line email sending tools, we’d consider SwithMail as one of the best in its class, if not the best. Instead of the need to write really long command line options to silently send an email where you might make mistakes and need a few tries to get it right, configuring SwithMail is quite foolproof thanks to the easy to use settings configuration GUI. You even test the email settings to make sure that it is able to successfully send an email.

swithmail configure settings

Other than the standard options such as attachments, CC, BCC that you’d normally find when sending an email, SwithMail supports returning error codes, global variables and wildcard attachments which is very useful to automatically send log files with dated filenames. Below is a working example of SwithMail command line options to send an email using Gmail account.

SwithMail.exe /s /from sender@gmail.com /pass YourGmailPassword /server smtp.gmail.com /p 587 /SSL /to recipient@email.com /sub subject /b message

Download SwithMail


2. CMail

If you need to use a command line email sending tool that supports proxy, CMail would be your choice as it’s the only one that can support socks and HTTPS based proxy. Other interesting features that can be found in CMail are sending the whole directory content based on wildcard attachment and delivery status notification.

The full working command line to send an email using Gmail is as follows:

CMail.exe -secureport -host:sender@gmail.com:YourGmailPassword@smtp.gmail.com:465 -from:sender@gmail.com -to:recipient@email.com -subject:subject -body:message

Download CMail


3. SendSMTP

Running SendSMTP will bring up an interactive graphical user interface to send emails but at the same time it also supports command line instructions to silently send email with just one line of commands. Although an advanced user would have no problems with the command line arguments, a GUI will greatly help a basic computer user in creating a working config file.

sendsmtp

Some notable features found in SendSMTP are the ability to save the password as encrypted using 128-bit Rijndael (AES) rather than saving the password as clear text, enable log file to save the activity of the SendSMTP program, and can return codes to report if the send email is successful (0), failed (1), or cannot find settings (2). The full command line for SendSMTP to send email using Gmail is as follow.

SendSMTP.exe /nos /host smtp.gmail.com /port 587 /auth 2 /userid sender@gmail.com /pass YourGmailPassword /from sender@gmail.com /to recipient@email.com /subject subject /body message

However, if you’ve saved the settings as default from the GUI which will create a SendSMTP.ini file at the same location as the program, a much shorter command line can be used to send an email.

SendSMTP /s SendSMTP.ini

Do note that there are 2 versions available on the download page. You will need the newer version with the bigger file size to support sending email using Gmail because the old version does not support SASL authentication.

Download SendSMTP


4. mailsend

Comparing with the utilities mentioned above, mailsend is a simpler command line tool to send email using SMTP. It doesn’t have fancy features such as loading config from an external file, password encryption, GUI, error codes and etc. However, an interesting feature found in mailsend that is not available on other command line email sending tool is the ability to show SMTP server information by using the -info option.

mailsend smtp info

mailsend is available for both Windows and Linux operating system. Below is the example command line for mailsend to send an email using Gmail.

mailsend1.17b15.exe -t recipient@email.com -f sender@gmail.com -ssl -port 465 -auth -smtp smtp.gmail.com -sub subject -M message -user sender@gmail.com -pass YourGmailPassword

Download mailsend


5. Send-It-Quiet

Send-It-Quiet is the smallest command line SMTP mailer utility that weighs only 14KB in size and this is made possible with .NET Framework. This would also mean that you need to have .NET Framework 3.5 installed to run Send-It-Quiet. Send-It-Quiet only comes with very basic parameters that are enough to send an email. Possibly the only extra features found in Send-It-Quiet are the return value of ERRORLEVEL and also the flexibility of manually adding the parameters to registry.

The command line to send an email using Send-It-Quite with a Gmail account is:

senditquiet.exe -s smtp.gmail.com -port 587 -u sender@gmail.com -protocol ssl -p YourGmailPassword -f sender@gmail.com -t recipient@email.com -subject subject -body message

Download Send-It-Quiet


6. SendEmail

SendEmail is written in Perl but there is no need to install Perl in Windows for this command line mailer utility to work. SendEmail was last updated in 2009, but the last version has TLS support which means it can send email using Gmail SMTP. In terms of features, it is quite similar to Send-It-Quiet which only supports the standard email sending options such as to, from, subject, body, attachment, etc. SendEmail is available for both Windows and Linux operating systems.

Here is an example of the command line options that can send email using Gmail SMTP.

sendEmail.exe -o tls=yes -f sender@gmail.com -t recipient@email.com -s smtp.gmail.com:587 -xu sender@gmail.com -xp YourGmailPassword -u subject -m message

Download SendEmail


7. PowerShell

PowerShell is included in Windows operating systems since Windows 7 which means you can actually use a powershell script to send an email through Gmail SMTP without any of the command line tools mentioned above.

powershell send email

The sample script that can be downloaded at the link below is a very basic one that is meant to only send an email without attachment support. Simply download the ps1 script, open it with Notepad or Windows PowerShell ISE and change the credentials located at line number 8. The command line to run the powershell script is as follows. Make sure you update the path to the .ps1 file.

Powershell.exe -executionpolicy remotesigned -File C:UsersRaymondsendemail.ps1

Download PowerShell Script to SendEmail


The popular Blat is not included in the list because it does not support SSL which means it cannot send email using Gmail SMTP. Bmail (last updated in 2004), cmdsendmail which is a part of CommandLine Tools, and XmlSendmail are also example of command line send mail utility that doesn’t support SSL.

Can anyone help me out, we need to send mail through command line from Window server. We cannot use Blat as per security issue and neither do we want to install Exchange resource kit. We have our own Mail exchange server we can make use of it.

May be if any batch which could be run to access our SMTP mail server.

Thanks in advance.

asked Mar 1, 2011 at 11:38

Ravi Vanapalli's user avatar

Ravi VanapalliRavi Vanapalli

9,7073 gold badges31 silver badges42 bronze badges

1

Assuming you don’t want to install any SMTP client whatsoever, and just want to use windows and perhaps batch files, you could use Telnet to connect to port 25 of your smtp server and send the commands manually.
Here is an example of how to do this.
Anyway, I personally would prefer to install some command line SMTP client such as Blat or Bmail, instead of going into the hassle of directly interacting with SMTP.

answered Mar 1, 2011 at 12:09

Amir Gonnen's user avatar

a very nice solution I found generically good if no authentication is involved and no programs can/should be installed or can be assumed to exist is the following, which should work on Ubuntu and other Linux platforms alike (you can put everything in one line using the ; command delimiter and removing the chars in the echo quoted string):

set sender="<sender@example.com>"
set recipient="<recipient@example.com>"
set subj="testsubj"
set body="testbody"
set srv="mysmtpsrv.com"
set port="25"
set crlf="x0Dx0A"

echo "EHLO man${crlf}
MAIL FROM: ${sender}${crlf}
RCPT TO: ${recipient}${crlf}
data${crlf}
Subject: ${subj}${crlf}${crlf}
${body}
${crlf}.${crlf}"
|
nc -Ci 1 ${srv} ${port}

(Using like this make sure you are saving the file in Unix style (only a x0A character will be added after the echo "... backslashes).
Otherwise just remove the backslashes and the newline which puts everything on a line and makes it work, but less visually structured.)

answered Dec 13, 2013 at 21:50

Andreas Covidiot's user avatar

Andreas CovidiotAndreas Covidiot

4,1285 gold badges48 silver badges95 bronze badges

HowToGeek demonstrates a Windows PowerShell script that works very well at How To Send Email From the Command Line in Windows Without Extra Software

Here is the method:
First you’re defining the variables:

$EmailFrom = “yourMail@gmail.com”
$EmailTo = “theRecipient’sAddress@someServer.com”
$Subject = “your subject”
$Body = “some text”
$SMTPServer = “smtp.gmail.com”
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“yourGmailUsername”, “password”);

Then, you’re using this command to send the mail:

$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)

You’ll need a valid Gmail account in order to authenticate as a Gmail user.

answered Dec 7, 2014 at 5:18

Oz Edri's user avatar

Oz EdriOz Edri

5515 silver badges8 bronze badges

To send mail from command line in windows:-
Save this in a text file and name that file something like sendmail.ps1

$EmailFrom = "from@gmail.com"

$EmailTo = "to@domain.com"

$Subject = "The subject of your email"

$Body = "What do you want your email to say"

$SMTPServer = "smtp.gmail.com"

$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)

$SMTPClient.EnableSsl = $true

$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("gmail_username", "password");

$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)

-Don’t forget to put the valid email address and password.

Now open CMD and write this command

Powershell -ExecutionPolicy ByPass -File C:sendmail.ps1

Voila! mail sent!!

answered Nov 27, 2015 at 11:05

GorvGoyl's user avatar

GorvGoylGorvGoyl

38.5k26 gold badges213 silver badges203 bronze badges

This is an example to send mail from your Gmail address, for other servers you need to change the -smtp and -port

$securepass = ConvertTo-SecureString -String $yourpassword -A -F

$credential=new-object PSCredential $yourusername,$securepass

send-mailmessage -from «$yourusername@gmail.com» -to $recipient -subject «subject» -body «message» -smtpserver smtp.gmail.com -port 587 -usessl -credential $credential -encoding utf8

Here is the script that can send mail from your Gmail:
https://gallery.technet.microsoft.com/scriptcenter/PC-Utilities-Downloader-355e5bfe

answered Mar 20, 2016 at 7:25

k8C's user avatar

k8Ck8C

4144 silver badges9 bronze badges

0

How To Send Email Locally Using Command Prompt

  1. Open Windows Command Prompt using Start > Command Prompt or via Run > CMD.
  2. Telnet to the mail server by typing telnet <domain> 25.
  3. Once connected, we must initiate the mail sending process queue. …
  4. Now we must set the sending mail address. …
  5. Now we set the to address. …
  6. Type data to begin the email content.
  1. How do I send an email from Windows?
  2. How do I send messages through command prompt Windows 10?
  3. How do I send an email from a batch file?
  4. How do I ping an email address from CMD?
  5. How do I send an email from Windows 10?
  6. How can I send email from my laptop to mobile?
  7. How do you send a message through CMD?
  8. Is the way to send message from one to another computer?
  9. How can I send a message to an IP address?
  10. How do I send an email to blat?
  11. What is Blat email?
  12. What is Sendmail EXE?

How do I send an email from Windows?

In this window, start by typing the person’s e-mail address you want to send the e-mail to in the «To:» field. Fill out a brief description of the message you’re sending in the Subject field. Type your message in the box below. Once your message is complete, click the Send button.

How do I send messages through command prompt Windows 10?

About This Article

  1. Click Command prompt.
  2. Type «msg USERNAME /server:SERVERNAME» and press Enter.
  3. Press Enter to send.

How do I send an email from a batch file?

To send an email using a batch file and PowerShell, we first need to create the PowerShell script to send an email. Once the script is built and saved, we can then call the PowerShell script from the batch file, a process is very similar to the VBscript method.

How do I ping an email address from CMD?

How to ping an email address

  1. Enable Telnet. Open the Start menu on your PC or laptop, go to Control Panel. There go to Programs, and then Features. …
  2. Find the mail server. In Search at the bottom of PC menu, search for “cmd” and click on a small black box – this opens the command prompt. Type nslookup –type=mx domain.com.

How do I send an email from Windows 10?

  1. From the Start menu, open the Mail app’s tile (shown here) and click the New Mail icon (it’s a plus sign icon) in the app’s top-right corner. …
  2. Type your friend’s email address into the To box. …
  3. Click in the Subject line and type a subject. …
  4. Type your message into the large box beneath the Subject line.

How can I send email from my laptop to mobile?

How to Send Emails From Your Computer to Mobile Phones

  1. Check what cell phone provider the recipient has. …
  2. Open your browser email or your email program.
  3. Click «Compose» or «New.»
  4. Type the recipient’s phone number, including area code in the «To» box.
  5. Type «@» after the phone number, and then the provider’s suffix.

How do you send a message through CMD?

Click Start > Run. Type cmd, and press Enter. In the window that opens, type Net send followed by the name of the computer to which you wish to send the message. Next, enter the message.

Is the way to send message from one to another computer?

How to send messages to other computers

  1. Instant messenger. An instant messenger program is often the easiest method of sending messages to other users on a network or other users on the Internet. …
  2. Microsoft Windows net send and winpopup commands. …
  3. Linux and Unix variants. …
  4. Other methods of communicating.

How can I send a message to an IP address?

Type «ipconfig /all» with a space between «ipconfig and /all». That will list the computer’s ip address along with other network specs. Now that you have the ip of that computer, you may send instant messages to it.

How do I send an email to blat?

Send mail use blat

  1. What is blat? Blat is a Windows (32 & 64 bit) command line utility that sends eMail using SMTP or post to usenet using NNTP. …
  2. Installation. blat -installSMTP smtp.gmail.com abc@gmail.com -u username -pw yourpasswd.
  3. Send mail. …
  4. Send email with body from a file. …
  5. specify charset of body file. …
  6. Send attachment.

What is Blat email?

Blat is a Public Domain Windows 95/NT console utility that sends the contents of a file in an e-mail message using the SMTP protocol. Blat is useful for creating scripts where mail has to be sent automatically (CGI, backups, etc.), or just as a quick way to send a file or message quickly from the command line.

What is Sendmail EXE?

sendmail.exe is a simple windows console application that emulates sendmail’s -t option to deliver emails piped via stdin. it is intended to ease running unix code that has /usr/lib/sendmail hardcoded as an email delivery means or program’s that use the sendmail pipe method, for example as php on windows uses.

SendItQuiet is a software for Windows that lets you send email from command line. It can also let you attach files and supports SSL connection. This software can be best to use for sending bulk emails from command line via a batch file. This software is capable of sending files as an attachment and supports sending emails to multiple recipients which can be supplied to the software as a parameter.

You would not require any kind of technical knowledge to use this tool to send email from command line. This software runs without any installation and can be used directly from the folder it is downloaded to. Read on to find out how to use this software.

Send email from command line - SendItQuiet - How to send an Email

Now, if you thought that it would be too difficult for you to understand this software then let me tell you that it is very easy to use this software.

Hope you know how to open up the command prompt but just so if you don’t know, press Windows Key (Key with Windows Logo) + R. The “Run” box will pop up. Once we get the Run Box, type in “cmd” and click on “OK”. There we go. We would have the command prompt.

Send Email from Command line - SendItQuiet - Opening command promt

SendItQuiet does not have a graphical interface. This means that we don’t have buttons and menus to click on and to choose from. It does not have text boxes where you can type in the email address. You might ask “How would we work with it?”. You would use the command prompt (Black Screen that we just pulled up) to provide the required information to the software. To invoke the software, we simply type the name of the software. Then we follow that with a few additional parameters that specify email address, server address, actual message, etc.

Ex: senditquiet -s smtp.gmail.com

Here, -s is used to specify that we’re going to provide the server’s address and “smtp.gmail.com” is the actual information we pass on to the software.

Different Parameters to Use with SendItQuiet:

SMTP (Simple Mail Transfer Protocol) server

The SMTP server is the server where we are going to connect to and the switch we use to specify this is “-s”.  Example: –s smtp.gmail.com. We have used Google’s SMTP server here for testing purposes. You can easily get the SMTP information from your Email provider on their website.

Protocol

Protocol is the way we connect with the server. We are going to use SSL (Secure Socket Layer), that means the information going out of the computer will be encrypted. Gmail uses this every time you want to send an email to someone. This is usually taken care of and happens in the background while your email client talks to the server.

We will specify it like this: “–protocol ssl”

Username and Password

Of course we would need the username and password to send the information to the Google’s SMTP and get our account verified. This is simple.

Specify –u for username, followed with actual usernam and –p for password., followed by actual password. Example: –u yourusername –p password

From and To Address

You need to type in the From Address that would show up on the receiver’s end. You would also need the receiver’s email address so that goes into the To Address.

Parameters for this: –t for To address and –f for from address.

Example: –f myemailaddress@gmail.com –t receiveremailaddress@yahoo.com

To send to multiple address: –t address1@gmail.com; address2@gmail.com; address3@yahoo.com

Subject and Body

What should go in there? Well, whatever you wish to put in there. You can specify the body and the subject with the “-subject” and “-body” parameters. Example: –subject “Test Mail” –body “This is a test mail from Ilovefreesoftware.com”

Ports

You would require to specify the port number in case if you’re Email service provider needs them desperately. For, Gmail the port is taken care by the software we are going to use. However, you should specify the port according to the specifications of the Email Service Provider.

Files

An email client without a feature to send files as an attachment would be absolutely incomplete. This software would let you do that. The parameter for this is: –files. Example: –files file1.txt, document.pdf, document.xls

To send an email from command line, the complete command would look like this:

senditquiet -s smtp.gmail.com -protocol ssl -u myusername -p password -f myemail@gmail.com -t recipientsemail@yahoo.com -subject "Test Mail" -body "This is a test mail." -files file1.doc

This is how it would look for real. I have used my Gmail account here. You can see the file – file1.txt sent with our software to send email from command line.

Send email from command line - SendItQuiet - Sending Email with attachment

How to use this software in a batch file?

To create a batch file, open up the Window’s Notepad or any of you’re favorite text editor. Once we’re in there, type in the command we want to go in there, one command per line. We can use SendItQuiet with more than one recipient and parameters with one command per line. Here is how we do it.

Send email from command line - SendItQuiet - Sending emails with batch file

We got for far, now it’s just the “File Saving” part left. We have to save this file as a .bat file. We choose the Save option from the File Menu and type in the name of the file and add .bat next to that as an extension. Now in the file type, we would choose All Files.

Send email from command line - SendItQuiet - Saving Batch File

Conclusion

SendItQuiet quickly lets you send email from command line. Because, it can also send files as an attachment, it can be used while sending bulk emails. It can completely automate the task of manual login and process of authentication. You can schedule emails and set it for a specific time to be sent out. It could be an hourly update of a file that you want to send as an email. The possibilities are many and this is just the beginning. I liked this tool and hope you’ll find it useful too.

Get SendItQuiet here for free

In this tutorial, we will learn how to send emails using PowerShell command lines or using a PowerShell script.

This tutorial is useful for anyone who wants to send emails automatically without using the browser or without using any application.

Sometimes it is necessary to create automatic alerts and send information about these events to your email or to other people’s emails. There are several ways to do this, on this tutorial we will use SMTP servers. These servers allow you to access the email account from which the email will be sent. Depending on the email account you will be using to send the email, the SMTP server will differ for each company or identity. For instance, the SMTP server of Gmail is smtp.gmail.com.

The first commands are very simple commands because they only create variables, objects and store the current date-time. The last one is not mandatory, it is only used for debugging and to demonstrate correct operationality.

$EmailFrom = "Source mail" # Put source mail between " "
$EmailTo = "Destiny mail" # Put destiny mail
$Subject = "Email Subject Here" # Insert the email subject

$Today = (Get-Date).DateTime # Get datetime not mandatory (only for mail information debug)

$Body = "This is mail body and the datetime is: " + $Today # Write message presented in mail
$SMTPServer = "smtp.emailproperty.com" # Put de SMTP server name (in my case is smtp.gmail.com)

The following command lines are responsible for creating the SMTP client object on port 587 and enabling the SSL certificate protocol. The port may be necessary to change depending on the email server that you will be using to send.

$SMTPClient = New-Object Net.Mail.SmtpClient($SMTPServer, 587) #Create object for SMTP server on 587 port
$SMTPClient.EnableSsl = $true # Enable SSL certificate Protocol

The following command lines are responsible for creating the credentials object, then you need to insert your source mail and your password account. This step will not give an error but may be necessary to change the password to an application password for security reasons that I will explain below.

# Create credentials object
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("Source mail", "Mail password");

The next is the last command line, it is responsible for connecting to the SMTP server and sending the mail.

# Send email using the created objects with all necessary data
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)

It is very likely that you will return a connection error if you have not entered all the data correctly or if the server does not allow you to connect in this way. If this last hypothesis happens then you should go to your email account and lower the security levels. If you don´t want to lower the security levels of your account, then you must create an application password and insert this password in the credentials command line. If you need help, please comment below.

The next code block is the summary of all the code you need, you can copy and paste this code into a file with extension “.ps1“.


$EmailFrom = "Source mail" # Put source mail between " "
$EmailTo = "Destiny Mail" # Put destiny mail
$Subject = "Email Subject Here" # Insert the email subject

$Today = (Get-Date).DateTime # Get datetime not mandatory (only for mail information debug)

$Body = "This is mail body and the datetime is: " + $Today # Write message presented in mail
$SMTPServer = "smtp.emailproperty.com" # Put de SMTP server name (in my case is smtp.gmail.com)



$SMTPClient = New-Object Net.Mail.SmtpClient($SMTPServer, 587) #Create object for SMTP server on 587 port
$SMTPClient.EnableSsl = $true # Enable SSL certificate Protocol

# Create credentials object
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("Source mail", "your password");

# Send email using the created objects with all necessary data
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)

You can use the commands directly on the command line by copying and pasting each command to the PowerShell window and press “Enter”, or you can use these commands in script form. The last way is powerful if you want to call this script automatically, so you can copy and paste it into a file with the extension “.ps1”. This type of extension is used for PowerShell scripts, for your information.
In the first time that you use these commands, I recommend using a command at a time, inserting it in the PowerShell window, and pressing “Enter”, because some unexpected errors may occur, and you will be able to read the error and understand what is happenning.

28 Replies

  • Author A.J. Stringham

  • Author da Beast

    You can modify this how-to and make it work for you — assuming you are going to be repeating this process.

    http://community.spiceworks.com/how_to/show/382-how-to-automatically-email-reports


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Dave Terrell

  • Author Shane Matthews

    Being an old fart, I used telnet from the command line for e-mail testing, assuming the appropriate ports are open. from the DOS box (Command Prompt for the young ‘uns) it’s;

    1. Telnet mail.domain.com 25 (obviously replace mail.domain.com with whichever mail server you want to use.)

    2. helo your domain name

    3. mail from:your email address

    4. rctp to:destination address

    5. data

    6. Type your message

    7. . (type a period and hit enter)

    At that point, your email message should be queued and sent. To make it a little clearer, here’s an example sending from fred.com to barney.com. Hit «enter after each line.

    1. telnet mail.barney.com 25

    2. helo fred.com

    3. mail from:fred@fred.com

    4. rcpt to:brubble@barney.com

    5. data Hello Barney. Bowling tonight?

    6. .

    Hope that makes sense.


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Robert Weiss

    You can always use the old standby telnet (you’ll probably need to enable telnet in windows features (control panel>>>programs>>>turn windows features on or off, then check the box next to telnet client):

    This is a good «how to» using an smtp server:

    http:/ Opens a new window/www.wikihow.com/Send-Email-Using-Telnet Opens a new window

    -Rob


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Boris Bondarenko

    +1 Shane

    Old school or not, I’ve used this more then once to troubleshoot mail servers. 


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Dan

    Blat.  

    IMHO, the absolute best command-line mailer for the windows platform.  hands down.  

    It’s supposed to (I think) support mapi, but I’ve always stuck with SMTP. If you don’t have a mail server to point to, you can always install the Windows SMTP service  (in there with IIS) and configure it to only accept/relay mail for 127.0.0.1

    and it has more logging/debugging options than you’ll likely ever need.


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Sean Harrigan

    I always use «telent <host> 25» like some of the other folks here for troubleshooting.

    Just a side note about telnet and Windows7, in case you weren’t aware, it’s not installed by default.  You have to go into Programs and Features and enable it via the «Turn Windows features on or off» dialog.


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Ahmad Abdullah

    http://www.smtpinfo.com/ Opens a new window — the free version should serve most purposes


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Andy Frith

    I also use Blat, mainly for emailing log files and results of batch scripts. Does the job nicely.


    Was this post helpful?
    thumb_up
    thumb_down

  • +1 for telnet, as described by Shane,

    best way to troubleshoot, got to be very careful with your typing, as you cannot backspace out errors, but very useful info returned to spot if something isn’t getting through


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Richard Kavanagh

    Powershell with one line

    send-mailmessage -from «fromname <me@address.com>» -to «toname <me@address.com>» -subject «Subject» -smtp <mailserver> -body «body»


    Was this post helpful?
    thumb_up
    thumb_down

  • Author John Barcelos

    OJB


    This person is a Verified Professional

    This person is a verified professional.

    Verify your account
    to enable IT peers to see that you are a professional.

    serrano

    +1 Shane

    You didn’t mention if you have a local mail server or hosting service. Your ISP may block port 25. If it’s a home pc port 25 is blocked by your ISP.


    Was this post helpful?
    thumb_up
    thumb_down

  • i use blat only because it was what i learned first, but really do like it and have gotten very comfortable scripting messages and setting them up as scheduled tasks.

     Still think that repeating a message to oneself in scheduled tasks every minute would make a great practical joke. 


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Douglas Rehfeldt

    I’ve used Blat in the past, but on Windows boxes this is what I mostly use now.  Save as a PS1 file and modify it to suit your environment.

    #  Send mail through Gmail account
    $EmailFrom = «notifications@somedomain.com»
    $EmailTo = «me@mydomain.com»
    $Subject = «Notification from Whomever»
    $Body = «this is a notification from Whatever Notifications..»
    $SMTPServer = «smtp.gmail.com»
    $SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
    $SMTPClient.EnableSsl = $true
    $SMTPClient.Credentials = New-Object System.Net.NetworkCredential(«username», «password»);
    $SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Robert Hartung

    Here’s another option. It’s called SendEmail. No install required. Handles authentication, if needed.

    http:/ Opens a new window/caspian.dotconf.net/menu/Software/SendEmail Opens a new window

    I use this to send e-mail through a scheduled task to confirm execution.


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Felton Frantz

    If moving to a new system or ISP with blat, make sure you are not trying to send pop3 smtp through an ssl account , unconfigured port, or ISP unsupported port.

    Even in debug mode, blat will grind to a halt with no diagnostics, only a generic windows error:

            «A Win32 command line eMail tool has stopped working»


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Helpdesk .

    to enable telnet from cmd

    sc config tlntsvr start= auto


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Gary Colefellow

    If you already have powershell installed, you can just call up the SmtpClient from System.Net and it’ll send whatever email you want. There’s a guide that explains sending email via the windows command line Opens a new window using powershell you can check out.


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Marek Lehocký

    This WORKS REALLY GREAT :-)  I spent hours to sent email from other clients with no luck ( not so good in emails:-) ). Here you got everything even with working examples. Thank you and have a nice day ;-)

    Google MailSend.   No need to mess with the Powershell.  http://muquit.com/muquit/software/mailsend/mailsend.html Opens a new window


    Was this post helpful?
    thumb_up
    thumb_down

  • Author D Kannan

    Sendmail utility in Windows is working fine.  But I am unable to attach a file.. Any reason..?

    I have given the command -attach=filename (with full path)


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Hari Rai

    Hey am tried this way but getting erro msg regarding argument


    Was this post helpful?
    thumb_up
    thumb_down

  • Author da Beast

    hari.p.rai wrote:

    Hey am tried this way but getting erro msg regarding argument

    Since there were multiple methods to do this presented in this thread you will need to provide more details.


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Hari Rai

    I tried following list of command:

    $EmailFrom = «notifications@somedomain.com»
    $EmailTo = «me@mydomain.com»
    $Subject = «Notification from Whomever»
    $Body = «this is a notification from Whatever Notifications..»
    $SMTPServer = «smtp.gmail.com»
    $SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
    $SMTPClient.EnableSsl = $true
    $SMTPClient.Credentials = New-Object System.Net.NetworkCredential(«username», «password»);
    $SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)

    through gmail i was to send but when i use my office id i am getting error regarding argument.


    Was this post helpful?
    thumb_up
    thumb_down

  • Author da Beast

    hari.p.rai wrote:

    I tried following list of command:

    $EmailFrom = «notifications@somedomain.com»
    $EmailTo = «me@mydomain.com»
    $Subject = «Notification from Whomever»
    $Body = «this is a notification from Whatever Notifications..»
    $SMTPServer = «smtp.gmail.com»
    $SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
    $SMTPClient.EnableSsl = $true
    $SMTPClient.Credentials = New-Object System.Net.NetworkCredential(«username», «password»);
    $SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)

    through gmail i was to send but when i use my office id i am getting error regarding argument.

    you are using BLAT and it works when you send via google but not using your office exchange?  Probably something wrong with 1 or more params with your office settings — or SMTP isn’t allowed from your terminal.


    Was this post helpful?
    thumb_up
    thumb_down

  • Author rrr rrr

    Hi

    There is a free utility called CommandLine Mail sender

    Here Opens a new window


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Paul Rowe

    Google reads, stores and shares your mail with NSA.  You may say there’s nothing to hide, but if the rules change, they can go back to the archives — apparently they are keeping a lot of this stuff, including encrypted stuff with an eye toward eventually being able to brute force decryption.

    Also you do not control the business policies of Google, its continuity,whether it is merged or acquired, nor whether and how it changes policies.  If you embed it in systems and decide later you don’t want to use it, or are unable to continue using it, or must maintain something in order to continue using a modified API, you’re a bit out of luck.

    Big, friendly, cool or not — I don’t entangle with other private parties without a contract and a proper business evaluation.

    FWIW,

    Greybeard who used Burroughs, IBM, Control Data, NCR, DEC, CompuServe, landlines, modems and a zillion other things that were likely to be part of the landscape forever.  Yeah, right.


    Was this post helpful?
    thumb_up
    thumb_down

  • Author John Doe

    There is a new and free command-line tool for sending emails called Mail Alert Simple Mailer:

    https://sourceforge.net/projects/mail-alert/ Opens a new window Opens a new window

    Mail Alert can send emails using SMTP servers with SSL/TLS, so it is working with gmail and other free email providers. It can save mail password in encrypted form, thus it is much safer then other solutions.

    I’m using this software on Windows Server 2008 R2 to send hardware alerts from Dell OMSA and is very reliable.


    Was this post helpful?
    thumb_up
    thumb_down

Read these next…

  • Curated Merging two domains with the same name?

    Merging two domains with the same name?

    Windows

    It seems that a possible company merger is coming down the pipeline, but as luck would have it, the active directory domains have the same name (ie, domain.local)The domain I maintain is running server 2019 at a 2016/2019 functional level.The other domain…

  • Curated How can I track changes to network adapter configuration

    How can I track changes to network adapter configuration

    Windows

    Ok, so we have a site where most of the users have local admin and they have a small group of users who «know about computers».  The site runs pretty smoothly but we’re seeing a bunch of users who are able to function on the wired network but aren’t able …

  • Curated Snap! -- Cooling in Antarctica, Back to the Moon, Biological Clothing, AI Sci-Fi

    Snap! — Cooling in Antarctica, Back to the Moon, Biological Clothing, AI Sci-Fi

    Spiceworks Originals

    Your daily dose of tech news, in brief.

    Welcome to the Snap!

    Flashback: February 3, 1986: The term “vaporware” is first used by Philip Elmer-DeWitt in a TIME magazine article (Read more HERE.)

    Bonus Flashback: February 3, 1966: Luna 9 Lan…

  • Curated Safety Glasses with Glasses

    Safety Glasses with Glasses

    Networking

    I’m going to be pulling some new wire soon through some dirty drop ceilings, and without fail, at some point I always get a piece of something in my eye at some point during the job.I’d like to avoid that this time.I have struggled to find safety glasses …

  • Curated AD on-premise courses

    AD on-premise courses

    IT & Tech Careers

    Hello!We have a predominantly on-prem AD environment. Whilst we will be moving to M365 that will be in a while.We have a number of junior staff that need basic instruction in Active Directory and file/folder permissions. I recall many years ago the MC…

How To Send Email Locally Using Command Prompt

This article serves as a guide to test simple email functionality on your server if you are unable to access your SmarterMail interface.  

  1. Open Windows Command Prompt using Start > Command Prompt or via Run > CMD
  2. Telnet to the mail server by typing telnet <domain> 25

  3. Once connected, we must initiate the mail sending process queue.  We start this with helo <domain> 

    The server will reply with 250 and a hello if successful.
     
  4. Now we must set the sending mail address.  Type mail from:<email address>

  5. Now we set the to address.  Type RCPT TO:<email address>


     

  6. Type data to begin the email content.
  7. First we set the subject by typing Subject:<Your Subject> Then press Enter twice.
  8. Now type the message content of your email.  When done, press Enter — Period Key — Enter to close the message.
  9. Type Quit to exit telnet. 

  10. Verify your email has been received.

Article ID: 2313, Created: November 21, 2015 at 12:49 AM, Modified: November 21, 2015 at 8:13 PM

I’ve got some backup jobs running weekly and would like to have the log files sent to me automatically via email so I don’t have to manually check them.

On a Windows system, is there a tool that I can use that will allow me to send an email via Gmail SMTP from a command prompt?

asked Dec 8, 2009 at 6:47

Matt Hanson's user avatar

Matt HansonMatt Hanson

9323 gold badges17 silver badges30 bronze badges

Gmail can be used for sending mail by any mail program and from any network.

Some command-line mail products for Windows are:

SendEmail
mailsend
(I have no first-hand experience with these products.)

See also this article : How to use Gmail as your SMTP server.

answered Dec 8, 2009 at 7:00

harrymc's user avatar

harrymcharrymc

430k30 gold badges495 silver badges876 bronze badges

1

Blat:

What is Blat?
Blat is a Win32 command line utility that sends eMail using SMTP or post to usenet using NNTP.

Jared Harley's user avatar

Jared Harley

12.4k3 gold badges40 silver badges51 bronze badges

answered Apr 19, 2011 at 23:17

Anonymous Cowardice's user avatar

HowToGeek demonstrates a Windows PowerShell script that works very well at How To Send Email From the Command Line in Windows Without Extra Software

Here is the method:
First you’re defining the variables:

$EmailFrom = “yourMail@gmail.com”
$EmailTo = “theRecipient’sAddress@someServer.com”
$Subject = “your subject”
$Body = “some text”
$SMTPServer = “smtp.gmail.com”
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“yourGmailUsername”, “password”);

Then, you’re using this command to send the mail:

$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)

You’ll need a valid Gmail account in order to authenticate as a Gmail user.

answered Dec 7, 2014 at 5:26

Oz Edri's user avatar

Oz EdriOz Edri

3753 silver badges8 bronze badges

Currently in powershell we can use Send-MailMessage cmdlet without using .NET:

$Credentials = New-Object System.Net.NetworkCredential(“yourGmailUsername”, “password”);
Send-MailMessage -From 'enterYourEmailHere ' -To 'enterRecipientMailHere' -Subject 'Email subject' -Body 'EnterBodyHere as HTML'  -Attachment 'Attachment path here' -SmtpServer 'smtp.gmail.com' -Port 587 -UseSSL -BodyAsHTML -Credential $Credentials 

Send-MailMessage Documentation

answered Aug 18, 2020 at 1:55

Wasif's user avatar

WasifWasif

7,5932 gold badges15 silver badges32 bronze badges

answered Aug 17, 2017 at 9:17

Pratik Singhal's user avatar

Понравилась статья? Поделить с друзьями:
  • Command r на обычной клавиатуре windows
  • Configuration manager windows 10 где находится
  • Command prompt windows 7 system restore
  • Command line option syntax error type command for help windows 10
  • Command delete file windows command line