Setting SMTP RelayIpList from a script.


SMTP service running on IIS 6.0 provides you options to restrict IP addresses of computers that can relay mail messages through this server.


relayrestrictions


The value(list of IP addresses) is stored in the RelayIpList metabase property as an octet string. I was recently contacted by a server administrator to figure out if there is an automatic script that can add IP addresses to this list. He wanted to add around 200 IP address and grant them access.


I have written a script that you can use in such scenarios. It reads IP addresses from a text file and populates them into the RelayIpList.



USAGE : cscript ImportRelayList.vbs


PREREQUISITE : This script needs ip.txt in the same folder.


Store your IP addresses in ip.txt FORMAT: Each line should be IP,MASK


ImportRelayList


I have attached the script to this blog post. Hope it helps.



Bookmark and Share

ImportRelayList.zip

Comments (12)

  1. Richard says:

    I would just like to say thanks for this scr1pt, just saved me some work doing something similar myself.

  2. Royce says:

    Thanks for the script.  I’m getting a:  

    runtime error:  Invalid procedure call or argument on (73, 13) where it’s trying to load the new IP/Mask array.

    Any ideas?

    Thanks,

    Royce Dunbar

  3. Bill says:

    I'm having the exact same error as Royce Dunbar.  Is there a fix???

  4. Bill Carson says:

    i am also getting the Invalid procedure call or argument on (73, 13)error,

    it will work if i only add a few address but not the 300+ that i need to add,

    the script overwrites any existing so i can add them incrementally,

    please help!

  5. Eddie says:

    Tried to use the script to save me some pain of manual entry. However, I am getting the "Invalid procedure call or argument on (72,13)"

    Seems like a common problem. Who has the answer?

  6. Rory Carlin says:

    I'm not sure what happened with the other guys that received the error.  The script worked perfectly for me.  Just imported 405 IP addresses successfully.  Many thanks Shinva 🙂

  7. Rramko says:

    If get this error "runtime error:  Invalid procedure call or argument on (73, 13)"

    check IP.txt file, If you have multiple IP addresses, you will get this error.

  8. darkstar3d says:

    Ensure that your IP list doesn't have duplicates, that causes errors

  9. Joey Ramirez says:

    Make sure to only use 255.255.255.255 Subnet mask, if not you will get the Invalid procedure call or argument on (73, 13).

  10. Nipi says:

    Awesome – this one really saved a lot of time.

    Good job. Thanks.

  11. Rohit says:

    You will get this error "Invalid procedure call or argument on (73, 13)" when the syntax is wrong in the list. Each line should be IP,MASK i.e 192.168.215.1,255.255.255.255.

    In my case out of 1795 rows, one row has 192.168.1.,255.255.255.255 and after removing/editing the entry, it worked fine for me.