You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Name

Send-JS7Mail

SYNOPSIS

Send e-mail

SYNTAX

Send-JS7Mail [-Server] <String> [-Port] <Int32> [-From] <String> [-To] <String[]> [-Subject] <String> [-Body] <String> [[-Cc] <String[]>] [[-Bcc] <String[]>] [[-Attachments] <String[]>] [[-Credential] <PSCredential>] [[-Timeout] <Int32>] [-BodyAsHtml] [-UseSSL] [[-SSLProtocol] <String>] [-UseDefaultCredentials] [<CommonParameters>]

DESCRIPTION

This cmdlet can be used to send e-mail.

The cmdlet will not work for mail servers that enforce SMTP over SSL instead of TLS, see https://docs.microsoft.com/en-us/dotnet/api/system.net.mail.smtpclient.enablessl?view=net-5.0

PARAMETERS

Server

-Server <String>
Host name or IP address of the SMTP mail server.

Required?true
Position?1
Default value
Accept pipeline input?true (ByPropertyName)
Accept wildcard characters?false

Port

-Port <Int32>
Numeric port for the SMTP protocol:
* Basic SMTP frequently makes use of port 25.
* Explicit SSL frequently makes use of port 587.
* Implicit SSL frequently makes use of port 465.

Required?true
Position?2
Default value0
Accept pipeline input?true (ByPropertyName)
Accept wildcard characters?false

From

-From <String>
The e-mail address that sends the information.

Required?true
Position?3
Default value
Accept pipeline input?true (ByPropertyName)
Accept wildcard characters?false

To

-To <String[]>
The recipient of the e-mail.

Required?true
Position?4
Default value
Accept pipeline input?true (ByPropertyName)
Accept wildcard characters?false

Subject

-Subject <String>
The subject of the e-mail.

Required?true
Position?5
Default value
Accept pipeline input?true (ByPropertyName)
Accept wildcard characters?false

Body

-Body <String>
The body of the e-mail. By default the body is plain text.
When using HTML e-mail consider to use the -BodyAsHtml switch.

Required?true
Position?6
Default value
Accept pipeline input?true (ByPropertyName)
Accept wildcard characters?false

Cc

-Cc <String[]>
The carbon copy recipients of e-mail.

Required?false
Position?7
Default value
Accept pipeline input?true (ByPropertyName)
Accept wildcard characters?false

Bcc

-Bcc <String[]>
The blind carbon copy recipients of e-mail.

Required?false
Position?8
Default value
Accept pipeline input?true (ByPropertyName)
Accept wildcard characters?false

Attachments

-Attachments <String[]>
Accepts an array of file names including the full path that should be attached to the e-mail.

Required?false
Position?9
Default value
Accept pipeline input?true (ByPropertyName)
Accept wildcard characters?false

Credential

-Credential <PSCredential>
The credential including user name and password of the account that authenticates with the SMTP mail server.
This parameter hqs to be specified for SMTP mail servers that require authentication.

A credential object can be created like this:
$mailCredential = New-Object System.Net.NetworkCredential( "info@sos-berlin.com", "secret" )

Required?false
Position?10
Default value
Accept pipeline input?true (ByPropertyName)
Accept wildcard characters?false

Timeout

-Timeout <Int32>
The timout in milliseconds that JS7 will wait for the connection to the mail server to be established.

Default: 15000

Required?false
Position?11
Default value15000
Accept pipeline input?true (ByPropertyName)
Accept wildcard characters?false

BodyAsHtml

-BodyAsHtml <SwitchParameter>

Required?false
Position?named
Default valueFalse
Accept pipeline input?true (ByPropertyName)
Accept wildcard characters?false

UseSSL

-UseSSL <SwitchParameter>
Forces one of Explicit SSL or Implicit SSL to be used.
Without this switch e-mail body and credentials will be sent as unencrypted plain text through the network.

Required?false
Position?named
Default valueFalse
Accept pipeline input?true (ByPropertyName)
Accept wildcard characters?false

SSLProtocol

-SSLProtocol <String>
This parameter can be used to specify the TLS protocol version that should be used. The protocol version is agreed
on between the mail server and the PowerShell client. Both server and client have to identify a common protocol version.

* -SSLProtocol 'Tls'
** use any TLS protocol version available
* -SSLProtocol 'Tls12'
** use TLS protocol version 1.2 only
* -SSLProtocol 'Tls11,Tls12'
** use TLS protocol version 1.1 or 1.2 only

Required?false
Position?12
Default value
Accept pipeline input?true (ByValue, ByPropertyName)
Accept wildcard characters?false

UseDefaultCredentials

-UseDefaultCredentials <SwitchParameter>
This parameter specifies that default credentials of the logged in user should be used if
SMTP authentication is required.

Required?false
Position?named
Default valueFalse
Accept pipeline input?true (ByPropertyName)
Accept wildcard characters?false

about_JS7

EXAMPLES

-------------------------- EXAMPLE 1 --------------------------

Send-JS7Mail -Server 'smtp.example.com' -Port 25 -To 'user@example.com' -Subject 'some subject' -Body '<html> <head><body>Hi there</body></head></html>' -BodyAsHtml -UseSSL

Sends an HTML e-mail via the respective mail server.

  • No labels