Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deferred emails use same ip - Routing not possible #430

Open
sotav opened this issue Oct 31, 2024 · 13 comments
Open

Deferred emails use same ip - Routing not possible #430

sotav opened this issue Oct 31, 2024 · 13 comments

Comments

@sotav
Copy link

sotav commented Oct 31, 2024

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
Copy link
Member

andris9 commented Oct 31, 2024

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

@sotav
Copy link
Author

sotav commented Oct 31, 2024

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
Copy link
Author

sotav commented Oct 31, 2024

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
Copy link
Contributor

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

@sotav
Copy link
Author

sotav commented Oct 31, 2024

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
Copy link
Contributor

louis-lau commented Oct 31, 2024

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
Copy link
Author

sotav commented Oct 31, 2024

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
Copy link
Member

andris9 commented Nov 1, 2024

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
Copy link
Author

sotav commented Nov 1, 2024

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
Copy link
Author

sotav commented Nov 1, 2024

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

@kostov531
Copy link

Hi @sotav, can you share your grafana query?

@sotav
Copy link
Author

sotav commented Nov 29, 2024

how do you need that ?

in a json of the dash - the panel only - the es queery ??

@louis-lau
Copy link
Contributor

@sotav

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

Your toml config merges with the default config, so you define those in your toml. That means your config was not being used for some reason, you should not have to modify default.js. It's in fact a pretty bad idea as it will be overwritten on the next npm install. In the zone-mta-template readme it also tells you how to see the merged config, you should probably see what's happening there to get the final config.

npm run config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants