If you need more info have a look in the bookmarks section on iptables:
http://www.linuxquestions.org/bookmarks/tags/iptables
And try to concentrate on the syntax that you would use to feed those commands into iptables buy hand.
What you need to realize that your script will actually perform this command (depending on your setup the interfaces eth0/1 differ):
Code:
iptables -A FORWARD -i eth0 -o eth1 -p tcp -s 117.234.23.123 --dport 587 -j ACCEPT
First start by learning to execute these commands by hand, and then later write scripts to execute these same commands.