Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F996026
smtp-mailer.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
smtp-mailer.ts
View Options
import
assert
from
"assert"
;
import
nodemailer
from
"nodemailer"
;
import
type
{
App
}
from
"../main"
;
import
Mailer
from
"./mailer"
;
import
type
{
MessageData
}
from
"./message"
;
export
default
class
SmtpMailer
extends
Mailer
{
mail_config
:
{
from_name
:
string
;
from_address
:
string
};
transport
:
nodemailer
.
Transporter
;
constructor
(
config
:
{
host
:
string
;
port
:
number
;
user
:
string
;
password
:
string
;
})
{
super
();
assert
(
typeof
config
.
host
==
"string"
);
assert
(
typeof
config
.
port
==
"number"
);
assert
(
typeof
config
.
user
==
"string"
);
assert
(
typeof
config
.
password
==
"string"
);
this
.
transport
=
nodemailer
.
createTransport
({
host
:
config
.
host
,
port
:
config
.
port
,
auth
:
{
user
:
config
.
user
,
pass
:
config
.
password
,
},
});
}
async
verify
()
{
return
this
.
transport
.
verify
();
}
async
init
(
app
:
App
)
{
await
super
.
init
(
app
);
this
.
mail_config
=
app
.
ConfigManager
.
get
(
"email"
);
}
async
sendEmail
({
to
,
subject
,
text
,
html
,
from_name
,
attachments
,
}
:
MessageData
&
{
from_name
:
string
})
{
return
this
.
transport
.
sendMail
({
from
:
`
${
from_name
||
this
.
mail_config
.
from_name
}
<
${
this
.
mail_config
.
from_address
}
>`
,
to
,
subject
:
subject
.
toString
(),
text
,
html
,
attachments
,
});
}
static
default_config
=
{
host
:
null
,
port
:
null
,
user
:
null
,
password
:
null
,
};
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Tue, Dec 24, 07:33 (1 d, 4 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
555982
Default Alt Text
smtp-mailer.ts (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment