- Get link
- X
- Other Apps
How to Send email using PowerShell from your own mailbox?
In this post, I will describe how we can send email using our own mailbox from PowerShell Command Line.
Well, sending email using PowerShell is pretty straightforward, this method requires you to authenticate with a service provider, we will use the SSL method to send the secure email.
Note: "$from" array will always be your mailbox primary Smtp, this mailbox will be auth in cloud service.
# type your mailbox userid and pass for O365 $cred = Get-Credential $From = $cred.username # this would be the smpt service Server address of the service provider $SMTPSrver ="SMTP.Office365.com" # Edit recipent & message details here $To = "someone@LetsExchange.in" $subject = "Your Email Subject" $Emailbody = "Your Email Body" $attachment = "Logs.txt"
# if you wish to attach any file in Email. Send-MailMessage -From $from -To $to -Subject $subject -Body $Emailbody ` -SmtpServer $SMTPSrver -Attachments $attachment -Credential $cred -UseSsl -Port 587
Comments
Post a Comment