Sending an email with Powershell

$SmtpServer = “yourServer”
$From =
if ($args.Length -lt 1) {
     $To =
else {
     $to = $args[0]
$subject = “Need computer consulting”
$Body = “Hi, this is John Doe I need cheap Exchange consulting at $125/hour”
$smtpClient = new-object
$ = $smtpServer
$smtpclient.send($from, $to, $subject, $body)
Once this file is saved to ps1 format you can use it via this syntax

Secure Exchange SMTP communication

Configuring postfix to use an SMTP relay

If you are like me and your ISP blocks SMTP outbounnd traffic then you need to configure your mail client to use an SMTP relay to get around this problem.  Here are the steps.
vi /etc/postfix/
do a search for relayhost = and change it to your SMTP server of your ISP see my example below.
relayhost =
/etc/init.d/postfix restart