Testing Open Relay / Allowed Relay using PowerShell

In my previous post, I posted a script which emails me move reports from office 365. A subset of that script emails using a non-authenticated connection.  This code allows you to test an open relay too… In many ways much easier than using Telnet. So here is that code again. 

     #SMTP server name
      $smtpServer = "relay.domain.com"
     #Creating a Mail object
      $msg = new-object Net.Mail.MailMessage
     #Creating SMTP server object
      $smtp = new-object Net.Mail.SmtpClient($smtpServer)
     #Email structure 
      $msg.From = "no-reply@domain.com"
      $msg.ReplyTo = "no-reply@domain.com"
      $msg.subject = "subject"
      $msg.IsBodyHTML = $false
      $msg.body = "Hello world, testing relay"
     #Sending email 

Author: Mike

owner of blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s