If you need more info have a look in the bookmarks section on 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):
iptables -A FORWARD -i eth0 -o eth1 -p tcp -s 188.8.131.52 --dport 587 -j ACCEPT
First start by learning to execute these commands by hand, and then later write scripts to execute these same commands.