Good afternoon, there are 2 different scripts on different servers. On each server base with different users. The problem is this, for example, on the first server, the administrator sends a mailing list. I want to send the same newsletter to users of the 2nd server. How to solve the problem more correctly without connecting to the base of the 2nd server from the first server. What interests you is not the code, but the very idea of ​​the solution. Thank you in advance.

  • and you imagine it yourself? You need either one script that will cling to two bases, or a script for each base. In the second case, you still have to take the data for sending from somewhere, i.e. cling to another base. - zenith
  • from the first server send a request to run the script on the second server. As a result, two scripts will run on two servers. - ReinRaus
  • 2
    For starters, I would advise you to read [this] [0]. Then you look and the world would become clearer :-) [0]: rusyaz.ru/pr - Chad
  • one
    I don’t teach you to write in my native language, I’m writing as much as I can if you could find mistakes, then you understood what I wanted to say.
  • 3
    If the forum were in your native language, they would be eligible. Read the rules for a start. That's what you wanted to say, I did not even try to understand. To ask questions in this way is at least not respect. - Chad

1 answer 1

On the second server, make an API through which the first server can interact with it. So, for example, when you need to do a mailing, your script on the first server, having done its work, pulls the api method from the second server, for example, SendMassMail, passes the mailing header, and the mailing text itself as arguments.

This example can be improved so that the script on the first server does not wait for a response from the second server. To do this, the api on the second server must be done in such a way that commands that do not require an immediate response are added to the task queue. Here, in theory, you can use some kind of task queue, or bicycling yourself something simple. If you make it so that you pull api on the second server, the SendMassMail method will take arguments from you, put them in the task queue, and complete its execution. This approach is recommended to be used on resources with a large number of users, or where performance of any functions takes an unacceptably long time.