Firewall – Gmail SMTP connection needs allow input in firewall – RouterOS

emailfirewallgmailmikrotiksmtp

I am trying to set-up Mikrotik (RouterOS v6.24) for sending emails.

I have google account and I am using SMTP connection. I know that I need to allow outbound connection for it to work. But when I try to send an email, the inbound filter will block connection and sending an email will fail.

16:37:04 firewall,info input: in:ether1-WAN out:(none), src-mac 00:13:60:16:4f:c6, proto TCP (SYN,ACK), 74.125.128.108:587->x.x.x.x:5462

When I disable the input filter. The email will be send correctly.

Why do I need to allow input connection for sending an email?

RouterOS settings:

   address: 74.125.128.108
       port: 587
  start-tls: yes
       from: xxxxx@gmail.com
       user: xxxxx
   password: xxxxxxxx
last-status: failed

Command used:

send to=xxxxx@xxxx.com from="xxxx@gmail.com" subject="test email" body="test body"

Best Answer

It appears that you don't allow established/related connections on the Input chain.

In order for the router to communicate with the outside world (be it smtp, or anything else) and you have a firewall on the input chain you need to allow any established/related connections back in to the router.

Simply add on the top of your input chain the following rule:

/ip firewall filter add chain=input connection-state=established,related action=accept