Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
5320e828
Commit
5320e828
authored
20 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Add multiple recipient support (comma-separate list, ala FormMail.pl).
parent
37421003
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
web/root/formmail.ssjs
+42
-30
42 additions, 30 deletions
web/root/formmail.ssjs
with
42 additions
and
30 deletions
web/root/formmail.ssjs
+
42
−
30
View file @
5320e828
...
...
@@ -44,17 +44,28 @@ var msgbase=new MsgBase("mail");
if
(
!
msgbase
.
open
())
results
(
LOG_ERR
,
format
(
"
%s opening mail base
"
,
msgbase
.
error
));
//------------------------
// Build the body text
//------------------------
var
i
;
var
body
=
"
Form fields follow:
\r\n\r\n
"
;
for
(
i
in
http_request
.
query
)
{
if
(
hidden_fields
[
i
])
continue
;
if
(
http_request
.
query
[
i
].
toString
().
length
)
body
+=
format
(
value_fmt_string
,
i
,
http_request
.
query
[
i
])
+
"
\r\n
"
;
}
body
+=
format
(
"
\r\n
via %s
\r\n
at %s [%s]
\r\n
"
,
http_request
.
header
[
'
user-agent
'
]
,
http_request
.
remote_host
,
http_request
.
remote_ip
);
//------------------------
// Build the e-mail header
//------------------------
var
hdr
=
{
from
:
'
FormMail
'
,
to
:
'
Sysop
'
,
subject
:
'
WWW Form Submission
'
};
// Use form-specified recipient
if
(
http_request
.
query
.
recipient
)
hdr
.
to
=
strip_ctrl
(
http_request
.
query
.
recipient
[
0
]);
// Use form-specified message subject
if
(
http_request
.
query
.
subject
)
hdr
.
subject
=
strip_ctrl
(
http_request
.
query
.
subject
[
0
]);
...
...
@@ -69,33 +80,34 @@ if(http_request.query.email && http_request.query.email.toString().length) {
if
(
http_request
.
query
.
realname
&&
http_request
.
query
.
realname
.
toString
().
length
)
hdr
.
from
=
strip_ctrl
(
http_request
.
query
.
realname
);
hdr
.
to_net_type
=
netaddr_type
(
hdr
.
to
);
if
(
hdr
.
to_net_type
!=
NET_NONE
)
hdr
.
to_net_addr
=
hdr
.
to
;
else
{
var
usrnum
=
system
.
matchuser
(
hdr
.
to
);
if
(
usrnum
==
0
)
results
(
LOG_ERR
,
"
bad local username specified:
"
+
hdr
.
to
);
hdr
.
to_ext
=
usrnum
;
}
//-------------------------
// Build the recipient list
//-------------------------
var
recipient
=
[
'
Sysop
'
];
//------------------------
// Build the body text
//------------------------
var
i
;
var
body
=
"
Form fields follow:
\r\n\r\n
"
;
for
(
i
in
http_request
.
query
)
{
if
(
hidden_fields
[
i
])
continue
;
if
(
http_request
.
query
[
i
].
toString
().
length
)
body
+=
format
(
value_fmt_string
,
i
,
http_request
.
query
[
i
])
+
"
\r\n
"
;
// Use form-specified recipient list
if
(
http_request
.
query
.
recipient
)
recipient
=
http_request
.
query
.
recipient
[
0
].
split
(
/
\s
*,
\s
*/
);
var
rcpt_list
=
[];
for
(
i
in
recipient
)
{
var
rcpt
=
{
to
:
strip_ctrl
(
recipient
[
i
])
};
rcpt
.
to_net_type
=
netaddr_type
(
rcpt
.
to
);
if
(
rcpt
.
to_net_type
!=
NET_NONE
)
rcpt
.
to_net_addr
=
rcpt
.
to
;
else
{
var
usrnum
=
system
.
matchuser
(
rcpt
.
to
);
if
(
usrnum
==
0
)
results
(
LOG_ERR
,
"
bad local username specified:
"
+
rcpt
.
to
);
rcpt
.
to_ext
=
usrnum
;
}
rcpt_list
.
push
(
rcpt
);
}
body
+=
format
(
"
\r\n
via %s
\r\n
at %s [%s]
\r\n
"
,
http_request
.
header
[
'
user-agent
'
]
,
http_request
.
remote_host
,
http_request
.
remote_ip
);
if
(
!
msgbase
.
save_msg
(
hdr
,
client
,
body
))
if
(
!
msgbase
.
save_msg
(
hdr
,
client
,
body
,
rcpt_list
))
results
(
LOG_ERR
,
format
(
"
%s saving message
"
,
msgbase
.
error
));
results
(
LOG_INFO
,
"
E-mail sent from
"
+
hdr
.
from
+
"
to
"
+
hdr
.
to
.
toString
().
italics
().
bold
()
+
"
successfully.
"
);
results
(
LOG_INFO
,
"
E-mail sent from
"
+
hdr
.
from
+
"
to
"
+
recipient
.
toString
().
italics
().
bold
()
+
"
successfully.
"
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment