//emails everyone active on the PDS if they have an email set in case of notifications of maintenance or issues //npm install @atcute/client //Make sure you have these env set. Does not share with the other email vars // PDS_MODERATION_EMAIL_SMTP_URL=smtps://blah // PDS_MODERATION_EMAIL_ADDRESS=pds@mypds import {Client, simpleFetchHandler} from '@atcute/client'; const YOUR_DID_ON_THE_PDS = "did:plc:"; const PDS_ADMIN_PASSWORD = "PDS_ADMIN_PASSWORD"; // Replace with actual password const PDS_HOSTNAME = "selfhosted.social"; const content = 'Can be or plain text' const subject = 'Email subject' const rpc = new Client({handler: simpleFetchHandler({service: `https://${PDS_HOSTNAME}`})}); let repos = await rpc.get('com.atproto.sync.listRepos', { params: { limit: 1000 } }) if (!repos.ok) { console.error(repos); } let activeRepos = repos.data.repos.filter(x => x.active); for (let repo of activeRepos) { const response = await fetch(`https://${PDS_HOSTNAME}/xrpc/com.atproto.admin.sendEmail`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'Basic ' + btoa(`admin:${PDS_ADMIN_PASSWORD}`) }, body: JSON.stringify({ recipientDid: repo.did, content, subject, senderDid: YOUR_DID_ON_THE_PDS }) }); if (!response.ok) { console.log(response); } const json = await response.json(); console.log(json); }