ML
    • Register
    • Login
    • Search
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups

    So you need a simple SMTP relay test? You can do it with P0werShell!

    IT Discussion
    9
    9
    1807
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • GregoryHall
      GregoryHall last edited by

      So you need a simple SMTP relay test for Office 365
      Introduction

      I have been doing a ton of Exchange migrations lately and setting up internal IIS relays to smarthost to Office 365. In this I have found many issues with firewalls and various settings IT managers like to do to keep email traffic limited. In this I have had to figure out ways to test SMTP from telnet to PowerShell and this one is my favorite so I thought I would share.

      Steps (4 total)
      1
      Open PowerShell
      Right Click on PowerShell and Run As Administrator

      2
      Store your Office 365 Mailbox Credentials
      get-credential will prompt you for the Office 365 relay mailbox creds. you need to store this in a variable so you can call it as one bit in the next command line.

      $relaycreds = get-credential

      3
      Use Send-MailMessage PowerShell Command
      now we can use the creds above to send a test email message using the Send-MailMessage command. [email protected] to the same user #you just stored the relaycreds in step one. [email protected] to another email address you have under your control so you can see it relay.

      Send-MailMessage –From [email protected] –To [email protected] –Subject “Test Email” –Body “Test SMTP Relay Service” -SmtpServer smtp.office365.com -Credential $relaycreds -UseSsl -Port 587

      4
      Test the SMTP Relay
      use the same command with a few changes to test the SMTP relay now.Do this from the server with IIS6 SMTP relay on or change localhost to the FQDN of your choice.

      Send-MailMessage –From [email protected] –To [email protected] –Subject “Test Email” –Body “Test SMTP Relay Service” -SmtpServer localhost -Port 25

      Conclusion

      So really simple way to send emails now and you can see also from this command the ability to email from a scheduled task attached to event triggers. This will help you monitor your windows servers for those specific events that you care about.

      Good luck

      1 Reply Last reply Reply Quote 9
      • scottalanmiller
        scottalanmiller last edited by

        Awesome, that is pretty cool. Thanks.

        1 Reply Last reply Reply Quote 0
        • Minion Queen
          Minion Queen Banned last edited by

          Thanks!

          1 Reply Last reply Reply Quote 0
          • IRJ
            IRJ last edited by

            Thanks! I was just talking about this with a friend the other day.

            1 Reply Last reply Reply Quote 0
            • Dominica
              Dominica last edited by

              Cool. This would have been handy for me to have a couple of years ago.

              1 Reply Last reply Reply Quote 0
              • Dashrender
                Dashrender last edited by

                Nice one.

                1 Reply Last reply Reply Quote 0
                • StrongBad
                  StrongBad last edited by

                  Good one, thanks.

                  1 Reply Last reply Reply Quote 0
                  • Ambarishrh
                    Ambarishrh last edited by

                    Thanks!

                    1 Reply Last reply Reply Quote 0
                    • M
                      Martin9700 last edited by

                      Port parameter wasn't introduced until PowerShell 3.0, so you'll need to make sure you're on at a minimum of that before this will work. PowerShell 4.0 is the current version and 5.0 is coming out SOON. So if you're still on 2.0, upgrade now!

                      1 Reply Last reply Reply Quote 4
                      • First post
                        Last post