Change Exchange Smart Host Port

By default, an Exchange server will try and send emails to a smart host using port 25. Unfortunately, there is no option to change the port number within the Exchange Management Console. This howto guide will show you how to change this to a different port number. This will be done using the Exchange Management Shell.

Note: Changing this setting will effect all traffic going through a send connector, so if you change it back to using DNS, it will try to connect to all mail servers on the specified port. This should stay as port 25, so only change this option when using a smart host, and the smart host requires you use a different port (eg, port 587).

Find out the identity of the send connector that you want to change the port number on.

Run the following command to get a list of the send connectors:


Use the relevant “Identity” name from the above output, and use the “Set-SendConnector” command as follows to set which port to use:

Set-SendConnector -identity "External Mail" -Port:587

This will set the send connector to sent emails to the smart host using port 587.

View current port setting:

If you want to find out which port is currently being used, you can use the following command:

Get-SendConnector -identity "External Mail" | Format-List

This will output the “Port” as one of the settings.

Adding a random signature to Outlook 2013

I was looking for a way to have a random signature in my mail (outlook). I didn't think I should need to resort to a full blown plugin/download to just do this simple task.

You can do this via the Developer tab in the Office Outlook client. If you dont have the developer ribon active you will have to enable it. You can do this via Options -> Customize Ribbon -> Tick the "Developer" checkbox and click OK. After adding it, go to the developer ribbon and click the "Visual Basic" button to go to the devekioer editor. Paste the following script in the "ThisOutlookSession" file.

Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
	If Item.Class <> olMail Then Exit Sub 'Make sure it's a send mail
    Const SearchString = "%Random_Line%"
    Const QuotesFile = "d:\quotes.txt" ' Path to file containing a quote per line

    If InStr(Item.Body, SearchString) Then
        If FileOrDirExists(QuotesFile) = False Then
            MsgBox ("Quotes file not found!")
            Cancel = True
            Dim lines() As String
            Dim numLines As Integer
            numLines = 0
            ' Open the file for reading
            Open QuotesFile For Input As #1
            ' Go over each line in the file and save it in the array + count it
            Do Until EOF(1)
                ReDim Preserve lines(numLines + 1)
                Line Input #1, lines(numLines)
                numLines = numLines + 1
            Close #1
            ' Get the random line number
            Dim randLine As Integer
            randLine = Int(numLines * Rnd()) + 1
            ' Insert the random quote
            Item.HTMLBody = Replace(Item.HTMLBody, SearchString, lines(randLine))
        End If
    End If
End Sub
Function FileOrDirExists(PathName As String)
    Dim iTemp As Integer
    On Error Resume Next
    iTemp = GetAttr(PathName)
    Select Case Err.Number
    Case Is = 0
        FileOrDirExists = True
    Case Else
        FileOrDirExists = False
    End Select
    On Error GoTo 0
End Function

This will replace the phrase %Random_Line% with a random line from the text file. If it can't open the text file it will not send the email out. Now you just need to edit your signature and place %Random_Line% where you like.