Pengembang bisa menggunakanan fungsi pada email untuk mengirim notifikasi menggunakan email.
ctx.moco.email;
Email methods
config(configuration)
Membuat configuration untuk nodemailer client.
Arguments
| name | type | description |
|---|---|---|
| configuration | object | data global configuration |
getClient()
Fungsi untuk mendapatkan email client.
Return
Promise<Object>
Mengembalikan instance client nodemailer.
sendWithTemplate(templateName, target, value)
Berfungsi untuk mengirim email dengan menggunakan template (ejs).
Arguments
| name | type | description |
|---|---|---|
| templateName | string | nama template |
| target | string / array | target email |
| value | object | value yang dimasukkan ke dalam template |
Return
Promise<Object>
Respon dari nodemailer.
send(message[Object])
Berfungsi untuk mengirim email berupa plain text.
message object properties
| name | type | description |
|---|---|---|
| from | string | email pengirim |
| to | string / array | target email |
| subject | string | subject email |
| text | string | text email |
| attachment | object | menambahkan attachment nodemailer |
Return
Promise<Object>
Respon dari nodemailer.