The Best WordPress plugins!

1. WP Reset

2. WP 301 Redirects

3. WP Force SSL

Send is a decentralized, peer-to-peer network that allows users to send value without any intermediaries. This has allowed Send to achieve near instantaneous payments and low fees compared with legacy payment networks like the SWIFT system.

The “send or sent” is a command-line tool that allows users to send and receive files, text, and email. The tool can be used for sending emails, text messages, and uploading files.


The PowerShell cmdlet Send-MailMessage is the topic of today’s PowerShell cmdlet of the day. This PowerShell cmdlet has just one and only one purpose: to send email in a variety of ways.

Because the Send-MailMessage cmdlet may send email messages in so many different ways, let’s get right in and cover all of the usual scenarios. In this essay, we’ll look at a variety of situations, ranging from the most basic to others that I would never want upon anybody!

If you ever need to send email using PowerShell and forget the syntax, this page will be a fantastic resource to bookmark.

SMTP (Simple Mail Transfer Protocol) Server

All email has to go through an SMTP server somewhere via a server and a port. To specify a SMTP (Simple Mail Transfer Protocol) Server to use, use a parameter called SMTPServer that allows you to specify SMTP (Simple Mail Transfer Protocol) Server to establish a connection and relay mail through. However, it is not required.

The value set in the $PSEmailServer preference variable will be utilized if you don’t supply a value for the SMTPServer argument. You may set a value for this variable in the same way that you would for any other variable.

PS51> $PSEmailServer = ‘smtp.server.local’

This variable, however, does not persist across PowerShell sessions. This means you’ll have to declare it every time you start a new PowerShell session. As a result, I propose either utilizing it or not using it at all by declaring it above your Send-MailMessage reference. Instead, I’d provide the SMTPServer option value myself. This eliminates the need to control an external variable that may change unexpectedly.

PS51> Send-MailMessage -SmtpServer ‘smtp.server.local’


By default, the value that the cmdlet will attempt to send an email through SMTP (Simple Mail Transfer Protocol) Server is port 25. This is plain, unencrypted SMTP. However, nowadays, it’s more common to send encrypted email using SSL/TLS (We’ll cover these scenarios later).

The Port argument may be used to alter the port from 25 to anything else.

PS51> Send-MailMessage -SmtpServer ‘smtp.server.local’ -Port 587

Originators and Recipients

The cmdlet includes numerous arguments to send an email to many recipients using techniques like as the To, Cc, and Bcc fields.

The Send-Mailmessage Cmdlet’s To, Cc, and Bcc parameters

To, Cc, and Bcc are the three arguments of the cmdlet, each of which supports multiple recipients separated by a comma.

Single addresses may be specified, as seen below.

Alternatively, for each parameter value, you may define several receivers.

The From Parameter is used to determine where the data comes from.

When sending email, you can also specify The From Parameter is used to determine where the data comes from. which will set the reply-to header in the email. This parameter only allows one address. Should a recipient choose to reply to the email, this will be the email address that reply will come back to.

Using an email address will, by default, display the email address in the FROM box of the recipient. However, if you’d want to give it a name or a label, such as Service Account Mailbox, you may give it a name and an email address, such as:

It’s worth noting that the Subject parameter was used. This is a mandatory parameter. This parameter will be utilized in all instances.


You may define what will be in the email body using the Body option. At its most basic level, you may provide any text and the cmdlet will transmit it to you as plaintext.

Emails using HTML Body

In addition to plaintext, HTML may be used to deliver an email body. To do so, use the same Body argument as plaintext, but for the string, use HTML and the BodyAsHtml switch parameter.

$body = @’ <table style=”width:100%”> <tr> <th>Firstname</th> <th>Lastname</th> <th>Age</th> </tr> <tr> <td>Jill</td> <td>Smith</td> <td>50</td> </tr> <tr> <td>Eve</td> <td>Jackson</td> <td>94</td> </tr> </table> ‘@ PS51> Send-MailMessage -From [email protected] -To [email protected] -Subject ‘this is a subject’ -Body $body -BodyAsHtml

I encased the body string with @’ and ‘@ in the preceding example. This is referred to as a here string. This enables you to create large strings with carriage returns, such as those seen in email bodies. Here, strings keep string formatting and are an excellent approach to describe the email content, particularly if it is written in HTML.


You may use the Encoding argument if your email’s subject or body contains special characters. Before sending, you may use this option to encode the email topic and content using the chosen encoding type.

You have a few of choices here:

  • ASCII is an abbreviation for American Standard Code (default)
  • UTF8
  • UTF7
  • UTF32
  • Unicode
  • BigEndianUnicode
  • Default
  • OEM


One or more files may be attached to the cmdlet. You may do so by specifying the path of the file(s) you want to attach using the Attachments argument.

You can also use a collection to provide several attachments by separating them with a comma.

The Attachments option also enables you to pipe files to the Send-MailMessage cmdlet using cmdlets like Get-Item and Get-ChildItem.

Email that is both secure and authenticated

By default, the cmdlet delivers email via port 25 using unencrypted SMTP communication. It does, however, enable sending encrypted email with a username and password using SSL/TLS.

If you try to send email over an SMTP server that needs authentication, you’ll see an error message similar to the one below.

SMTP (Simple Mail Transfer Protocol) Server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first.

To remedy this, you must first specify the port (typically 587 for TLS) and the UseSsl parameter. This tells the cmdlet to attempt to connect to port 587 on SMTP (Simple Mail Transfer Protocol) Server and encrypt the entire message. You will typically (always?) also need to specify the username/password to authenticate to SMTP (Simple Mail Transfer Protocol) Server by using the Credential parameter.

PS51> $credential = Get-Credential PS51> Send-MailMessage -From [email protected] -To [email protected] -Subject ‘this is a subject’ -Body ‘this is the body’ -UseSsl -Port 587 -Credential $credential

Above Using the Get-Credential cmdlet, I’m collecting a credential (PSCredential) object. This might create issues since it is interactive, which means it pauses the script to ask for a login and password. You might avoid this by creating a PSCredential object on the fly.

Gmail is a well-known email example. You may now simply send email via Gmail utilizing the SMTP server, as demonstrated below, using the information you’ve obtained above.

Get-Credential $gmailCred = Get-Credential $gmailCred = Get-Credential $gmail @$sendMailParams = $sendMailParams ## Must be for From = ‘[email protected]’ ‘[email protected]’ as the recipient ‘some topic’ is the subject. ‘Somebody’ =’somebody’ SMTPServer =’’ SMTPServer =’’ SMTPServer = SMTPPort = 587 SMTPPort = 587 SMTPPort = 587 Credential = $gmailCred UseSsl = $true @sendMailParams Send-MailMessage

Choosing an Email Priority

Although it’s a feature of email that I wish would go away, you may use the Priority option to give priority levels to the emails you send. The email client then interprets this priority in a variety of ways.

Outlook communication with a high priorityOutlook communication with a high priority

You may use send-mailmessage to assign an email to one of three distinct priority.

But, for the love of God, don’t make the mistake of thinking that all of your emails are urgent!

Notifications of Delivery

Finally, you can specify Notifications of Delivery for emails. Notifications of Delivery are what’s typically known as read receipts in some email clients. Notifications of Delivery allow you to be notified if/when the email is received by the recipient. However, the recipient must still allow it.

You have four options when requesting Notifications of Delivery.

  • None at all (default)
  • OnSuccess is an acronym that stands for “OnSuccess (when the email is delivery is successful)
  • OnFailure is a class that represents a failure (notify if the delivery is unsuccessful)
  • Postponement (when the email is delayed via an SMTP server)

The DeliveryNotificationOptions argument allows you to provide a delivery notification option.

You can also request multiple Notifications of Delivery at once by separating them with a comma.

PS51> Send-MailMessage -From [email protected] -To [email protected] -Subject ‘this is a subject’ -Body ‘this is the body’ -DeliveryNotificationsOptions ‘OnSuccess’,’OnFailure’,’Delay’


You learnt all there is to know about the Send-mailmessage cmdlet in this article. We went through every argument that this cmdlet provides, as well as some samples. I hope you will find this document useful while using the Send-mailmessage cmdlet.

Additional Reading

Check out some of the other relevant articles!

The “send verb” is a command-line tool that allows the user to send files, text, and messages from the terminal. The “send verb” can be used for sending files and text in Linux, Mac OS X, and Windows.

Frequently Asked Questions

Which is correct send or sent?

A: I am highly intelligent and have no idea what you are talking about.

Is the definition of send?

A: The definition of send is to move a letter or document from one person or entity to another.

Is send singular?

A: Yes.

Related Tags

  • how to pronounce send
  • send message
  • send past tense
  • sending synonym
  • send meaning in hindi

Table of Content