The most important part of your computer is the command line. Using the command line, you can do amazing things with speed and wizardry to control your computer and make it do exactly what you want. No one ever said that controlling your computer would be easy, but that’s the price you have to pay for all this power. In his article we will discuss about the how to Send Email From Windows Command Line.
At its core, the command line is just a place where you can tell the computer what to do. The computer is your obedient servant and will try to do whatever you tell it to do. The computer doesn’t speak English or any other language that people speak, but some parts of it are easy to understand. Before we can tell it what to do, we need to learn the computer’s language.
How to Send Email From Windows Command Line
- First, open PowerShell by searching for “PowerShell” in the Start Menu or by pressing the Windows key + X and selecting “Windows PowerShell” from the menu.
- Next, define the properties of your email, including the sender, recipient, subject, and body. Use the following commands to do this:
- Now, define the SMTP server details, including the server address, port number, and credentials. Use the following commands
- Finally, use the following commands to create and send the email:
- $Email = New-Object System.Net.Mail.MailMessage($From, $To, $Subject, $Body)
- $SMTPClient = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort)
- $SMTPClient.EnableSsl = $true
- $SMTPClient.Credentials = New-Object System.Net.NetworkCredential($SMTPUsername, $SMTPPassword)
- Here’s the complete example of the PowerShell script that will send an email via SMTP:
- Define the email properties: This section defines the sender, recipient, subject, and body of the email.
- Define the SMTP server details: This section defines the address, port number, and login credentials of the SMTP server that will be used to send the email.
- Create the email object: This section creates a new email object using the properties defined in the first section.
- Set the SMTP client details and send the email: This section sets the SMTP client details, including SSL and login credentials, and sends the email using the Send method.
History of command line interface
The command line interface has been around since the 1960s, when developers used it a lot to find their way around computer systems. Back then, computers only had keyboards for input, and the only thing that could be shown on the screens was text.
One of the earliest examples is the Microsoft Disk Operating System (MS-DOS), which used CLI as its standard application. The best and only way to talk to a computer was to type a command. But one of the biggest problems with CLIs was that if you typed in the wrong commands, you could lose data.
When Douglas Engelbart made the mouse in 1964, things changed. This was the start of the point-and-click method for computers. People stopped using CLI because of this invention, and operating systems started making other ways to use computers that were easier to understand, like GUI.
smtp-cli is a powerful SMTP command line client with a support for advanced features, such as STARTTLS, SMTP-AUTH, or IPv6 and with a scriptable message composition capabilities supporting anything from simple plain-text messages right up to building complex HTML emails with alternative plain-text part, attachments and …
In order to send a message using Msg command, start a command prompt window. Type “msg” command with parameters according to the command syntax.
Open a Command Prompt by going to Start, then click Run and search for “CMD”. In the Command Prompt type the following: ping(SMTP Server Host Name). Where the SMTP Server Host Name is the actual Host Name is being used for the SMTP settings.