Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F7188346
smtp-mailer.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
997 B
Referenced Files
None
Subscribers
None
smtp-mailer.js
View Options
const
assert
=
require
(
"assert"
);
const
nodemailer
=
require
(
"nodemailer"
);
class
SmtpMailer
{
constructor
(
app
)
{
const
config
=
app
.
ConfigManager
.
get
(
"smtp"
);
assert
(
typeof
config
.
host
==
"string"
);
assert
(
typeof
config
.
port
==
"number"
);
assert
(
typeof
config
.
user
==
"string"
);
assert
(
typeof
config
.
password
==
"string"
);
this
.
mail_config
=
app
.
ConfigManager
.
get
(
"email"
);
this
.
transport
=
nodemailer
.
createTransport
({
host
:
config
.
host
,
port
:
config
.
port
,
auth
:
{
user
:
config
.
user
,
pass
:
config
.
password
,
},
});
}
async
verify
()
{
return
this
.
transport
.
verify
();
}
async
sendEmail
({
to
,
subject
,
text
,
html
,
from_name
,
attachments
})
{
return
this
.
transport
.
sendMail
({
from
:
`
${
from_name
||
this
.
config
.
from_name
}
<
${
this
.
mail_config
.
from_address
}
>`
,
to
,
subject
,
text
,
html
,
attachments
,
});
}
}
SmtpMailer
.
default_config
=
{
host
:
null
,
port
:
null
,
user
:
null
,
password
:
null
,
};
module
.
exports
=
SmtpMailer
;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jul 8, 08:08 (1 d, 10 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
810442
Default Alt Text
smtp-mailer.js (997 B)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment