Update files
This commit is contained in:
parent
097b545cd7
commit
9ebdd81c48
|
|
@ -72,14 +72,23 @@ VITE_MODERATION_API_URL=https://moderation.nkm.guru/api
|
|||
OWNER_EMAIL=aaem9848@gmail.com
|
||||
|
||||
# Email настройки для отправки писем (выберите один вариант)
|
||||
|
||||
# AWS SES
|
||||
# EMAIL_PROVIDER=aws
|
||||
# AWS_SES_ACCESS_KEY_ID=your_aws_access_key
|
||||
# AWS_SES_SECRET_ACCESS_KEY=your_aws_secret_key
|
||||
# AWS_SES_REGION=us-east-1
|
||||
# EMAIL_FROM=noreply@nakama.guru
|
||||
|
||||
# Yandex Cloud Postbox (совместим с AWS SES API)
|
||||
EMAIL_PROVIDER=aws
|
||||
AWS_SES_ACCESS_KEY_ID=your_aws_access_key
|
||||
AWS_SES_SECRET_ACCESS_KEY=your_aws_secret_key
|
||||
AWS_SES_REGION=us-east-1
|
||||
AWS_SES_ACCESS_KEY_ID=your_yandex_access_key
|
||||
AWS_SES_SECRET_ACCESS_KEY=your_yandex_secret_key
|
||||
AWS_SES_REGION=ru-central1
|
||||
AWS_SES_ENDPOINT_URL=https://postbox.cloud.yandex.net
|
||||
EMAIL_FROM=noreply@nakama.guru
|
||||
|
||||
# Или Yandex Cloud
|
||||
# Или Yandex SMTP
|
||||
# EMAIL_PROVIDER=yandex
|
||||
# YANDEX_SMTP_USER=your_email@yandex.ru
|
||||
# YANDEX_SMTP_PASSWORD=your_app_password
|
||||
|
|
@ -94,3 +103,8 @@ EMAIL_FROM=noreply@nakama.guru
|
|||
# SMTP_SECURE=false
|
||||
# EMAIL_FROM=noreply@nakama.guru
|
||||
|
||||
|
||||
docker-compose stop backend
|
||||
docker-compose rm -f backend
|
||||
docker-compose build -no-cache backend
|
||||
docker-compose up -d backend
|
||||
|
|
@ -97,7 +97,8 @@ module.exports = {
|
|||
aws: {
|
||||
accessKeyId: process.env.AWS_SES_ACCESS_KEY_ID,
|
||||
secretAccessKey: process.env.AWS_SES_SECRET_ACCESS_KEY,
|
||||
region: process.env.AWS_SES_REGION || 'us-east-1'
|
||||
region: process.env.AWS_SES_REGION || 'us-east-1',
|
||||
endpoint: process.env.AWS_SES_ENDPOINT_URL || null // Для Yandex Cloud Postbox: https://postbox.cloud.yandex.net
|
||||
},
|
||||
yandex: {
|
||||
host: process.env.YANDEX_SMTP_HOST || 'smtp.yandex.ru',
|
||||
|
|
|
|||
|
|
@ -10,11 +10,35 @@ const initializeEmailService = () => {
|
|||
const emailProvider = process.env.EMAIL_PROVIDER || 'aws'; // aws, yandex, smtp
|
||||
|
||||
if (emailProvider === 'aws' && config.email?.aws) {
|
||||
sesClient = new AWS.SES({
|
||||
const awsRegion = config.email.aws.region || 'us-east-1';
|
||||
const validAWSRegions = [
|
||||
'us-east-1', 'us-east-2', 'us-west-1', 'us-west-2',
|
||||
'eu-west-1', 'eu-west-2', 'eu-west-3', 'eu-central-1',
|
||||
'ap-southeast-1', 'ap-southeast-2', 'ap-northeast-1',
|
||||
'sa-east-1', 'ca-central-1'
|
||||
];
|
||||
|
||||
// Проверка на Yandex Cloud Postbox (использует ru-central1)
|
||||
const isYandexCloud = awsRegion === 'ru-central1';
|
||||
const endpointUrl = config.email.aws.endpoint || process.env.AWS_SES_ENDPOINT_URL ||
|
||||
(isYandexCloud ? 'https://postbox.cloud.yandex.net' : null);
|
||||
|
||||
const sesConfig = {
|
||||
accessKeyId: config.email.aws.accessKeyId,
|
||||
secretAccessKey: config.email.aws.secretAccessKey,
|
||||
region: config.email.aws.region || 'us-east-1'
|
||||
});
|
||||
region: awsRegion
|
||||
};
|
||||
|
||||
// Для Yandex Cloud Postbox нужен кастомный endpoint
|
||||
if (endpointUrl) {
|
||||
sesConfig.endpoint = endpointUrl;
|
||||
console.log(`[Email] Используется Yandex Cloud Postbox с endpoint: ${endpointUrl}`);
|
||||
} else if (!validAWSRegions.includes(awsRegion)) {
|
||||
console.warn(`[Email] Невалидный регион AWS SES: ${awsRegion}. Используется us-east-1`);
|
||||
sesConfig.region = 'us-east-1';
|
||||
}
|
||||
|
||||
sesClient = new AWS.SES(sesConfig);
|
||||
} else if (emailProvider === 'yandex' || emailProvider === 'smtp') {
|
||||
const emailConfig = config.email?.[emailProvider] || config.email?.smtp || {};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue