Page 1 of 1

PHPMailer not working with Firewall

Posted: Tue Mar 24, 2015 8:30 am
by mehargags
On one of My Debian 7 installs, I'm not able to send mails through PHPMailer which sends mails via Google SMTP (regardless of EXIM on server)

If I stop Firewall -- it sends through but not when Firewall is active.

I have ACCEPT for 993,465,25,587 in the Rules.... anything ?

iptables -L

Code: Select all

Chain INPUT (policy DROP)
target     prot opt source               destination
fail2ban-VESTA  tcp  --  anywhere             anywhere             tcp dpt:8083
fail2ban-MAIL  tcp  --  anywhere             anywhere             multiport dports smtp,ssmtp,submission,2525,pop3,pop3s,imap2,imaps
fail2ban-SSH  tcp  --  anywhere             anywhere             tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:9562
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:5901
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:2257
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:9810
DROP       tcp  --  anywhere             anywhere             tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere             multiport dports http,https
ACCEPT     tcp  --  anywhere             anywhere             multiport dports ftp-data,ftp,12000:12100
ACCEPT     udp  --  anywhere             anywhere             udp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere             multiport dports smtp,ssmtp,submission,2525
ACCEPT     tcp  --  anywhere             anywhere             multiport dports pop3,pop3s
ACCEPT     tcp  --  anywhere             anywhere             multiport dports imap2,imaps
DROP       tcp  --  anywhere             anywhere             multiport dports mysql,postgresql
DROP       tcp  --  anywhere             anywhere             tcp dpt:8083
ACCEPT     icmp --  anywhere             anywhere
ACCEPT     all  --  127.0.0.2            anywhere
ACCEPT     all  --  rn2g                 anywhere
ACCEPT     all  --  localhost.localdomain  anywhere
ACCEPT     tcp  --  anywhere             anywhere             tcp spt:ftp-data
ACCEPT     tcp  --  anywhere             anywhere             tcp spt:ftp
ACCEPT     tcp  --  anywhere             anywhere             tcp spt:ssh
ACCEPT     tcp  --  anywhere             anywhere             tcp spt:smtp
ACCEPT     udp  --  anywhere             anywhere             udp spt:domain
ACCEPT     tcp  --  anywhere             anywhere             tcp spt:http
ACCEPT     tcp  --  anywhere             anywhere             tcp spt:https
ACCEPT     tcp  --  anywhere             anywhere             tcp spt:pop3
ACCEPT     udp  --  anywhere             anywhere             udp spt:ntp
ACCEPT     tcp  --  anywhere             anywhere             tcp spt:imap2
ACCEPT     tcp  --  anywhere             anywhere             tcp spt:mysql
ACCEPT     tcp  --  anywhere             anywhere             tcp spt:postgresql
ACCEPT     tcp  --  anywhere             anywhere             tcp spt:http-alt
ACCEPT     tcp  --  anywhere             anywhere             tcp spt:8433
ACCEPT     tcp  --  anywhere             anywhere             tcp spt:8083
ACCEPT     udp  --  google-public-dns-a.google.com  anywhere             udp spt:domain state ESTABLISHED
ACCEPT     tcp  --  google-public-dns-a.google.com  anywhere             tcp spt:domain state ESTABLISHED
ACCEPT     udp  --  google-public-dns-b.google.com  anywhere             udp spt:domain state ESTABLISHED
ACCEPT     tcp  --  google-public-dns-b.google.com  anywhere             tcp spt:domain state ESTABLISHED

Re: PHPMailer not working with Firewall

Posted: Tue Mar 24, 2015 5:06 pm
by skurudo

Code: Select all

/etc/init.d/iptables-persistent restart
?

Re: PHPMailer not working with Firewall

Posted: Tue Mar 24, 2015 5:32 pm
by mehargags
skurudo wrote:

Code: Select all

/etc/init.d/iptables-persistent restart
?
isn't that a CentOS command ? I'm on Debian7

Code: Select all

ah@2yg:~$ /etc/init.d/iptables-persistent restart
-bash: /etc/init.d/iptables-persistent: No such file or directory

Re: PHPMailer not working with Firewall

Posted: Tue Mar 24, 2015 5:43 pm
by skurudo
iptables -A OUTPUT -p tcp --dport 25 -j ACCEPT
iptables save

Re: PHPMailer not working with Firewall

Posted: Tue Mar 24, 2015 6:14 pm
by mehargags
doesn't help.

I think IP Tables are screwed.

I tested on CentOS with Firewall enabled, it works -

I think Vesta's Scripts do not configure Firewall properly on Debian systems.

Re: PHPMailer not working with Firewall

Posted: Wed Mar 25, 2015 10:09 am
by skurudo
Try to flush iptables and make you own rules

Re: PHPMailer not working with Firewall

Posted: Wed Mar 25, 2015 2:50 pm
by mikho
put the rules in the custom.sh file and restart the firewall using vesta commands.
Should work.