zone-eu / zone-mta

📤 Modern outbound MTA cross platform and extendable server application
European Union Public License 1.2
606 stars 96 forks source link

Deferred emails use same ip - Routing not possible #430

Open sotav opened 1 week ago

sotav commented 1 week ago

Hello !

We have 2 servers each with multiple (7 outgoing) ips for a single domain and the problem I face is that i have no way to route the deferred emails to use the ip that was selected when the email was sent the first time . This creates an issue with the first ip that is binded to the server as it get blocked from RBL lists, as all the deferred emails that goes out using that specific ip only and when the amount of retries is like 5 times the total emails are too many for a single ip and it gets blocked

So my question is : is there any way to be able to route the deferred emails from the ip that was selected from zone-mta to be transmitted the first time .

I would really appreciate for any guidance or help that can be provided

andris9 commented 1 week ago

Do you have different instance id’s (queue.instanceId config) configured for each ZoneMTA server?

sotav commented 1 week ago

Yes both are different servers using their own backend mongo and redis ! if that is what you are asking Sir Andris

if you talking about each sending zone no ... all use the same as i am not sure how to change that for each sending zone and i use only one queue .toml file

so each server has this content of that file

############################################## instanceId="default" collection="zone-queue" gfs="mail" disableGC=false ##############################################

sotav commented 1 week ago

The problem for example is like this :

172.0.20.20 primary ip not used to send emails as it is not set to receive emails on any port (p1)

172.0.20.21 secondary ip 1 (s1) 172.0.20.22 secondary ip 2 (s2) 172.0.20.23 secondary ip 3 (s3)

so if i sent 30 emails in total sent 10 emails from s1 ip sent 10 emails from s2 ip and 10 emails from s3 ips

and 5 from s1 gets deferred , 5 from s2 and 5 from s3 then 15 emails goes out from p1 ip multiplied * the retries /5 times = 70

so the primary ip even though i do not use it to send emails to and from - it gets 70 emails to deliver which is more tan double the amount of initial emails and 7 times more from each ip !

and i have no way to set the deferred emails to use the same ip (something like the "sticky ip ") that was used to send the first email

louis-lau commented 1 week ago

I'm pretty sure deferred emails are sticky to the initial delivery ip. That's not what you're seeing?

sotav commented 1 week ago

nope ! and that is why i am in trouble with this case

as i have a prerouting process and deliver each email to different secondary ip , to be delivered from (in a way as zone-mta uses routing on its own using ip pools and routing based on receipient domain , sender domain and headers ). so every message haveits own incoming--delivery ip

for example the 30 email i sent , i sent 10 to each ip as zone mta listens to each ip for incoming messages.

louis-lau commented 1 week ago

I don't really understand what you're doing, if I'm being honest. Zonemta is designed to use a single mongodb for multiple hosts and multiple ips. There is no prerouting process needed. I was under the assumption that you had these 3 ips added to a single zonemta, but they're 3 completely separate instances?

sotav commented 1 week ago

Well sorry for not making my self clear on this. i ll try my best !

i have 2 instances (servers) each server has a mongodb and a redis service and a zone mta installed

So now lets get only the first server on the server zone mta uses it localhost installed mongo db and a localhost redis

it has 8 ips 1 primary and 7 extra ips attached to it

when i start zone mta only the 7 secondary interfaces are being enabled to receive or send emails as i keep the primary (feeder) only to manage the server remotely now on the pools i have 3 pools with all the ips inside each pool and on the selection of the pools to use is based on recipient domain

so ....

i sent 7 emails 1 to each secondary ip - without any X-sending-header - as that is managed through the pool using recipient domain and round robin the selection of the 7 ips i have on that pool

now what happens is that every email out of the 7 emails goes through a seperate ip as i have 7 ips

and here comes the problem

every deferred email goes only from the primary ip and not the secondary that was first initiated

for example i sent 1 email to S1 for a gmail recipient S2 for a gmail recipient S3 for a gmail recipient S4 for a gmail recipient S5 for a gmail recipient S6 for a gmail recipient S7 for a gmail recipient

all emails goes through the pool [gmail] every ip is sending 1 email each

then 3 emails gets deferred cause of "user over quota" - soft bounce

and the deferred email on the next try to be sent are usiing the P1 ip whioch is the primary ip even that i did not use that ip to deliver the email to the zone-mta

this makes the primary ip to be blocked cause of the amount of retries to send the deferred emails

I hope i made more clear now !

and my question is- is there any way to manage the deferred email to use the initiated ip that was used to send the email the first time when the email got deferred ?

and thank you in advance for the time you spent to help resolve my issue

andris9 commented 1 week ago

ZoneMta always uses the original ip for sending deferred emails. Tbh I can’t even think of a reason why it would behave like you describe.

sotav commented 1 week ago

So if i understand correctly there is something i have configured wrongly as what i describe is true . I will try to recreate the whole - maybe i have change something that i should not have changed !

Once again thank you for your time.

sotav commented 1 week ago

Well the problem was resolved with an amazing way !!

i have set up zone-mta-template and did the config and first init of the app as it was requested from the readme file !

εικόνα

configured all the toml files and everything was ok

but 1 more step needs to be there and that is cause of the zone-mta-template needs the module..... zone-mta inside of node_modules as the zone-mta-limiter and all the rest !

"/zone-mta-template/node_modules/zone-mta"

but inside that module there is another config /default.js file

and as that had no ips configured on the default pool - maybe it was that which was using the primary ip

so i just added the secondary ips on that file under the default pool restarted zone-mta and that did the trick ! (crazy but true )

problem solved !!

PoC

εικόνα

and for the stats thing now - the results are these :

2024-11-01 12_58_12-

Please let me know if you need any further info about the same