Do i need to open 25 port to send emails with the php mail function?
php mail() function relies on sendmail like binary to send mail.
any MTA ( service listening on port 25 ) has program like sendmail that will serve the purpose.
if you don't want to have port 25 open, you can firewall it for all connections comming from the world; for example
iptables -I INPUT -p tcp -i eth0 --dport 25 -j REJECT
No.
As long as your firewall rules permit outbound traffic you do not need to open port 25 to send an email.
Port 25 only needs to be open if you wish your machine to receive email.