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
903f9735
Commit
903f9735
authored
7 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Added example use of log_text_filename.
Use alert(), since we have it.
parent
c044032f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
exec/mailproc_example.js
+23
-3
23 additions, 3 deletions
exec/mailproc_example.js
with
23 additions
and
3 deletions
exec/mailproc_example.js
+
23
−
3
View file @
903f9735
...
...
@@ -20,6 +20,8 @@
load
(
"
mailproc_util.js
"
);
log
(
"
Hello from mailproc_example.js
"
);
// Set to false at any time to indicate a processing failure
var
success
=
true
;
...
...
@@ -27,21 +29,39 @@ var success=true;
// If there are any processing errors (e.g. filtered context, blocked sender),
// you can reject the message by simply writing some text to 'errfile'.
var
errfile
=
new
File
(
processing_error_filename
);
if
(
!
errfile
.
open
(
"
w
"
))
if
(
!
errfile
.
open
(
"
w
"
))
{
alert
(
"
Failed to open
"
+
processing_error_filename
);
exit
();
}
// This block opens a log debug output file, which is a bit unnecessary
// in a JS mailproc since you could/should just use the log() function
// directly, but for native mailprocs, it could be handy for debugging
var
logfile
=
new
File
(
log_text_filename
);
if
(
!
logfile
.
open
(
"
w
"
))
{
alert
(
"
Failed to open
"
+
log_text_filename
);
exit
();
}
logfile
.
writeln
(
"
1
"
);
logfile
.
writeln
(
"
2
"
);
logfile
.
writeln
(
"
3
"
);
// These lines read the recipient list into a new 'recipient' object array.
var
rcptlst
=
new
File
(
recipient_list_filename
);
if
(
!
rcptlst
.
open
(
"
r
"
))
if
(
!
rcptlst
.
open
(
"
r
"
))
{
alert
(
"
Failed to open
"
+
recipient_list_filename
);
exit
();
}
var
recipient
=
rcptlst
.
iniGetAllObjects
(
"
number
"
);
// At this point we can access the list of recipients very easily
// using the 'recipient' object array.
// These lines open the message text file in append mode (writing to the end)
var
msgtxt
=
new
File
(
message_text_filename
);
if
(
!
msgtxt
.
open
(
"
a+
"
))
// Change the mode to "r+" for "read/update" access
if
(
!
msgtxt
.
open
(
"
a+
"
))
{
// Change the mode to "r+" for "read/update" access
alert
(
"
Failed to open
"
+
message_text_filename
);
exit
();
}
// Create an object (associative array) of header field strings
var
header
=
parse_msg_header
(
msgtxt
.
readAll
());
...
...
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