import 'dotenv/config'; const username = process.env.SMS_USERNAME; const password = process.env.SMS_PASSWORD; const sender = process.env.SMS_SENDER; if (!username || !password || !sender) { console.error('Missing SMS env vars'); process.exit(1); } const text = 'Montime code: 123456'; const targets = process.argv.slice(2).length ? process.argv.slice(2) : ['09397439581', '09128081392']; function escapeXml(value) { return String(value) .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, '''); } for (const mobile of targets) { const soapBody = ` ${escapeXml(username)} ${escapeXml(password)} ${escapeXml(text)} ${escapeXml(mobile)} ${escapeXml(sender)} `; const res = await fetch('https://webservice.0098sms.com/service.asmx', { method: 'POST', headers: { 'Content-Type': 'text/xml; charset=utf-8', SOAPAction: 'http://tempuri.org/SendSMS', }, body: soapBody, signal: AbortSignal.timeout(20000), }); const body = await res.text(); const match = body.match(/]*>([^<]*)<\/SendSMSResult>/); console.log(mobile, 'HTTP', res.status, 'RESULT', match?.[1] ?? body.slice(0, 200)); }