-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbulkmail.js
92 lines (63 loc) · 1.86 KB
/
bulkmail.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// bulkmail.js
// Bulk email all users that match AR String input
// written by the hanged man, Solace BBS, solace.synchro.net
load("sbbsdefs.js");
const REVISION = "$Revision: 1.6 $".split(' ')[1];
print("Synchronet BulkMailer " + REVISION);
print("Enter ARS matches to send mail to or [ENTER] for everyone");
printf("ARS to match: ");
if((ars=console.getstr(40,K_UPPER))==undefined)
exit();
printf("\r\n\1y\1hSubject: ");
if((subj=console.getstr(70,K_LINE))=="")
exit();
fname = system.temp_dir + "bulkmsg.txt";
file_remove(fname)
console.editfile(fname);
if(!file_exists(fname)) // Edit aborted
exit();
file = new File(fname);
if(!file.open("rt")) {
log(LOG_ERR,"!ERROR " + errno_str + " opening " + fname);
exit();
}
msgtxt = lfexpand(file.read(file_size(fname)));
file.close();
delete file;
if(msgtxt == "")
exit();
msgbase = new MsgBase("mail");
if(msgbase.open()==false) {
log(LOG_ERR,"!ERROR " + msgbase.last_error);
exit();
}
var u; // user object
lastuser=system.lastuser;
var sent=0;
var rcpt_list=new Array();
for(i=1; i<=lastuser; i++)
{
u = new User(i);
if(u.settings&(USER_DELETED|USER_INACTIVE))
continue;
if(!u.compare_ars(ars))
continue;
/*checking for netmail forward */
if(u.settings&USER_NETMAIL && u.netmail.length)
hdr = { to_net_addr: u.netmail, to_net_type: netaddr_type(u.netmail) };
else
hdr = { to_ext: String(u.number) };
hdr.to = u.alias;
rcpt_list.push(hdr);
printf("Sending mail to %s #%u\r\n", u.alias, i);
log(format("Sending bulk mail message to: %s #%u", u.alias, i));
sent++;
}
hdr = { from: system.operator, from_ext: "1", subject: subj };
if(!msgbase.save_msg(hdr, msgtxt, rcpt_list))
log(LOG_ERR,"!ERROR " + msgbase.last_error + "saving bulkmail message");
msgbase.close();
if(sent>1) {
print("Sent bulk mail to " + sent + " users");
log("Sent bulk mail message to " + sent + " users");
}