If you get "500 Illegal PORT command.", you are using the active mode, not the passive mode. Double check that and make sure to really use the passive mode.
For an explanation of the error message (even though in different context), see:
ftp_get: Illegal PORT command.