@andrey4emk/npm-app-back-b24 0.5.14 → 0.5.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/sendMessage/email.js +9 -9
package/package.json
CHANGED
package/sendMessage/email.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import nodemailer from "nodemailer";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
4
|
+
* @param auth - объект с данными для авторизации в почте
|
|
5
|
+
* @param auth.user - пользователь (почта)
|
|
6
|
+
* @param auth.pass - пароль или app password
|
|
7
7
|
*/
|
|
8
8
|
export class Email {
|
|
9
|
-
constructor(
|
|
9
|
+
constructor(auth) {
|
|
10
|
+
this.auth = auth;
|
|
10
11
|
this.transporter = nodemailer.createTransport({
|
|
11
12
|
auth: {
|
|
12
|
-
user:
|
|
13
|
-
pass:
|
|
13
|
+
user: this.auth.user,
|
|
14
|
+
pass: this.auth.pass,
|
|
14
15
|
},
|
|
15
16
|
host: "smtp.yandex.ru",
|
|
16
17
|
port: 465, // 465 = SMTPS, 587 = STARTTLS
|
|
@@ -46,8 +47,8 @@ export class Email {
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
const info = await this.transporter.sendMail({
|
|
49
|
-
from: `Натяжные потолки Репа. <${this.
|
|
50
|
-
to: [dataMail.to, this.
|
|
50
|
+
from: `Натяжные потолки Репа. <${this.auth.user}>`, // адрес отправителя
|
|
51
|
+
to: [dataMail.to, this.auth.user], // строка или массив адресов
|
|
51
52
|
subject: dataMail.subject,
|
|
52
53
|
text: dataMail.text,
|
|
53
54
|
html: dataMail.html, // html-версия
|
|
@@ -71,7 +72,6 @@ export class Email {
|
|
|
71
72
|
// Возвращаем буфер
|
|
72
73
|
return { error: false, buffer: buffer };
|
|
73
74
|
} catch (error) {
|
|
74
|
-
logs.add(`Ошибка при скачивании файла по fileUrl: ${error.message}`, "error");
|
|
75
75
|
return { error: true, message: `Ошибка при скачивании файла по fileUrl: ${error.message}` };
|
|
76
76
|
}
|
|
77
77
|
}
|