Send email via Powershell

If you want to send an email via Powershell, e.g. to test if a local SMTP server is able to receive incoming email, you can use the following Powershell command:

Send-MailMessage -SmtpServer 192.168.1.10 -Port 25 -From leendert@lanedirt.tech -To test@lanedirt.tech -Subject test -Body test

Replace the example values in the command above to the credentials used in your situation:

  • -SmtpServer
    • Servername (DNS) or IP address of the server which is able to receive email
  • -Port
    • The port of the SMTP server. By default this is port 25.
  • -From
    • The email address of the sender.
  • -To
    • The email address of the receiver.
  • -Subject
    • Subject of the email.
  • -Body
    • Body of the email.

Published
Categorized as Powershell

By Leendert de Borst

Freelance software architect with 10+ years of experience. Expert in translating complex technical problems into creative & simple solutions.

Leave a comment

Your email address will not be published. Required fields are marked *