Send-SmtpMail
SYNOPSIS
PSCX Cmdlet: Sends email via specified SMTP server to specified recipients.
SYNTAX
Authenticated (Default)
Send-SmtpMail [-InputObject <PSObject>] [-SmtpHost <String>] [-PortNumber <Int32>] [-Credential <PSCredential>]
[-PassThru] [-From <String>] [-ReplyTo <String>] -To <String[]> [-Cc <String[]>] [-Bcc <String[]>]
[-Subject <String>] [-Body <String>] [-AttachmentPath <PscxPathInfo[]>]
[-AttachmentLiteralPath <PscxPathInfo[]>] [-Timeout <Int32>] [-HtmlBody] [-Priority <MailPriority>]
[-Width <Int32>] [-WhatIf] [-Confirm] [<CommonParameters>]
Anonymous
Send-SmtpMail [-InputObject <PSObject>] [-SmtpHost <String>] [-PortNumber <Int32>] [-Anonymous] [-PassThru]
[-From <String>] [-ReplyTo <String>] -To <String[]> [-Cc <String[]>] [-Bcc <String[]>] [-Subject <String>]
[-Body <String>] [-AttachmentPath <PscxPathInfo[]>] [-AttachmentLiteralPath <PscxPathInfo[]>]
[-Timeout <Int32>] [-HtmlBody] [-Priority <MailPriority>] [-Width <Int32>] [-WhatIf] [-Confirm]
[<CommonParameters>]
DESCRIPTION
Sends email via specified SMTP server to specified recipients. This cmdlet checks for existence of several preference that if set can make this cmdlet much easier to use. Those preference variables are:
* $PscxSmtpHostPreference="smtp.example.net"
* $PscxSmtpPortPreference=587
* $PscxSmtpFromPreference="john_doe@example.net"
EXAMPLES
EXAMPLE 1
PS C:\>
Send-SmtpMail -SmtpHost smtp.example.net -To jane_doe@example.net `
-From john_doe@example.net -Subject "Hi there" -Credential (get-credential) `
-Body @"
>> Hi Jane,
>> Let's do lunch.
>> --
>> John"
>> "@
>>
PARAMETERS
-To
Specifies who the email will be sent to.
Type: System.String[]
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Anonymous
Connect to SMTP host anonymously.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: Anonymous
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-AttachmentLiteralPath
Specifies literal paths (no wildcard expansion) to attachments for the email.
Type: Pscx.IO.PscxPathInfo[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-AttachmentPath
Specifies paths to attachments for the email.
Type: Pscx.IO.PscxPathInfo[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Bcc
Specifies who to BCC on the email.
Type: System.String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Body
Specifies the body of the email.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Cc
Specifies who to CC on the email.
Type: System.String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Credential
Specifies credentials required to aunthenticate on the SMTP host.
Type: System.Management.Automation.PSCredential
Parameter Sets: Authenticated
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-From
Specifies who the email is from.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: Value of $PscxSmtpFromPreference if defined, otherwise null.
Accept pipeline input: False
Accept wildcard characters: False
-HtmlBody
Indicates that the body of the message is HTML.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-InputObject
Input objects are rendered to text using Out-String and placed in the body of the message. The Width parameter can be used to control the width of string generated by Out-String.
Type: System.Management.Automation.PSObject
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
-PassThru
Causes the MailMessage object to be passed to the next stage of the pipeline.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-PortNumber
Specifies which port to use on the SMTP host.
Type: System.Nullable`1[System.Int32]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: Value of $PscxSmtpPortPreference if defined, otherwise 25.
Accept pipeline input: False
Accept wildcard characters: False
-Priority
@{Text=}
Type: System.Net.Mail.MailPriority
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-ReplyTo
Specifies who replies to the email will be sent to.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-SmtpHost
Specifies which SMTP host to use to send the email.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: Value of $PscxSmtpHostPreference if defined, otherwise null.
Accept pipeline input: False
Accept wildcard characters: False
-Subject
Specifies the subject of the email.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Timeout
Specifies timeout for SMTP Server.
Type: System.Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: 100 seconds.
Accept pipeline input: False
Accept wildcard characters: False
-Width
Specifies the width for Out-String to render pipeline input objects to text.
Type: System.Nullable`1[System.Int32]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: Out-String default width is used if Width not specified.
Accept pipeline input: False
Accept wildcard characters: False
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.