robinklaassen / aas2

Anderwijs Administratie Systeem
1 stars 1 forks source link

Sync emails from aas #157

Open blackshadev opened 3 years ago

blackshadev commented 3 years ago

Direct admin has an API to sync email adresses, why not use it.

I used this script where each line in emails.txt was in the form of vincent@anderwijs.nl --> vinnie@script4web.nl The $SECRET was obtained from the chrome debugging tab, no clue how to get it without it, but it should be possible.

while IFS= read -r line
do
   curl --request POST \
        --url 'https://s183.webhostingserver.nl:2223/CMD_EMAIL_FORWARDER?json=yes' \
        --header 'Content-Type: application/x-www-form-urlencoded' \
        --cookie session=$SECRET \
        --data json=yes \
        --data action=create \
        --data "raw_forwarders=$line"
done < emails.txt
blackshadev commented 3 years ago

You can add login keys to the account and use them as HTTP basic with to use the DA API. The username remains the normal username, the password will be the login key.

The api is really badly documented , but you can see the API calls when accessing the DirectAdmin Panel via the chrome network tab

robinklaassen commented 3 years ago

Als we dit gaan doen dan moeten we niet vergeten om voor leden een vinkje "niet in iedereen@" toe te voegen want er is op dit moment 1 lid die dat heeft (ben namelijk op ADHD controle van de ledenlijst aan het doen).