Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F9583325
email.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
email.js
View Options
const
assert
=
require
(
"assert"
);
const
SmtpMailer
=
require
(
"./smtp-mailer"
);
const
LoggerMailer
=
require
(
"./logger-mailer"
);
const
environment_to_mailer
=
{
dev
:
LoggerMailer
,
production
:
SmtpMailer
,
};
module
.
exports
=
app
=>
{
let
environment
;
let
config
;
let
mailer
;
app
.
ConfigManager
.
setDefault
(
"email"
,
{
from_name
:
"Noreply"
,
from_address
:
"example@example.com"
,
});
app
.
ConfigManager
.
setDefault
(
"smtp"
,
SmtpMailer
.
default_config
);
return
{
async
init
()
{
config
=
app
.
ConfigManager
.
get
(
"email"
);
assert
(
typeof
config
.
from_name
===
"string"
);
assert
(
typeof
config
.
from_address
===
"string"
,
"Please set a config value for 'email.from_address'"
);
environment
=
app
.
ConfigManager
.
get
(
"core.environment"
);
mailer
=
new
environment_to_mailer
[
environment
](
app
);
return
mailer
.
verify
();
},
async
send
(
message
)
{
return
mailer
.
sendEmail
({
to
:
message
.
to
,
subject
:
message
.
subject
,
text
:
message
.
text
,
html
:
message
.
html
,
attachments
:
message
.
attachments
,
from_name
:
app
.
ConfigManager
.
get
(
"email.from_name"
),
});
},
};
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 11, 09:23 (1 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
960583
Default Alt Text
email.js (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment