Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F12657465
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
Fri, Nov 28, 15:18 (2 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1077341
Default Alt Text
email.js (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment