In iMS 5.1 relaying is controlled by IP addresses. In other words when a connection arrives the ip addr of the client is checked against the INTERNAL_IP mapping, if a match is found then the client is allowed to send mail to anywhere.
If the client ip addr is not found in that mapping table then they are only allowed to send mail to users in the iMS messaging system.
The error message you gave shows that you were connecting from a machine that was not in the list of allowed ip addresses to relay mail and that you were trying to send a message to an address that was not local to the iMS messaging system.
The mapping I am referring to is in msg-<instance>/imta/config/mappings, then look for a mapping table called INTERNAL_IP
When you've made the changes you want then
msg-instance/imsimta cnbuild
msg-instance/imsimta restart dispatcher