Mail Servisi
StabilSMTP yapılandırması, e-posta şablonları, raw/template mail gönderimi ve log yönetimi bu servis üzerinden gerçekleştirilir.
Mail servisi proje bazlı SMTP ayarı saklar, default veya projeye özel template kullanır, doğrudan raw mail gönderebilir ve gönderim loglarını kayıt altına alır.
Genel Bakış
Mail Servisi, EVDSOFT mikro servis mimarisinde merkezi e-posta katmanıdır. Bir proje için SMTP ayarları kaydedilebilir, o projeye özel template'ler tanımlanabilir, domain veya projectId üzerinden mail gönderimi yapılabilir ve tüm gönderimler loglanabilir.
Servis Özeti
Base Pattern
/api/mail/*
Internal Headers
X-Internal-Service-Token / X-Internal-Service-Name
Sorumluluklar
SMTP Konfigürasyonu
Projeye ait SMTP ayarlarını kaydeder, getirir ve test eder.
Template Yönetimi
Default veya projeye özel e-posta şablonlarını tanımlar ve listeler.
Template ile Gönderim
Domain veya proje bağlamında değişkenli şablon e-postaları gönderir.
Raw Mail Gönderimi
Hazır subject/bodyHtml/bodyText ile doğrudan mail gönderir.
Mail Logları
Son gönderimleri durum, konu, alıcı ve template bilgileriyle listeler.
Kimlik Doğrulama
GET /api/mail/health dışında örnek isteklerdeX-Internal-Service-Token veX-Internal-Service-Name header'ları kullanılıyor. Mail servisi iç servis çağrıları için tasarlanmış görünüyor.
Not
success,message,data vetimestamp alanlarını döner. Hata örneklerinde ise ek olarakerror,path vestatus alanları da bulunur.API Endpoint'leri
Health Check
/api/mail/healthMail servisinin ayakta olduğunu doğrular. Kimlik doğrulama gerektirmez.
Yanıt Örneği
{
"data": {
"service": "MAIL-SERVICE",
"status": "UP"
},
"message": "Mail service ayakta.",
"success": true,
"timestamp": "2026-03-07T01:22:13.4362855"
}SMTP Ayarları
/api/mail/projects/{projectId}/smtp-configBir proje için SMTP ayarlarını kaydeder veya günceller.
Headers
| İsim | Değer | Zorunlu |
|---|---|---|
| X-Internal-Service-Token | {{platformKey}} | Evet |
| X-Internal-Service-Name | AUTH-SERVICE | Evet |
| Content-Type | application/json | Evet |
İstek Örneği
{
"host": "smtp.hostinger.com",
"port": 465,
"username": "[email protected]",
"password": "your-password",
"fromEmail": "[email protected]",
"fromName": "EVDSOFT",
"replyTo": "[email protected]",
"sslEnabled": true,
"tlsEnabled": false,
"active": true
}Yanıt Örneği
{
"data": {
"active": true,
"fromEmail": "[email protected]",
"fromName": "EVDSOFT",
"host": "smtp.hostinger.com",
"id": 1,
"port": 465,
"projectId": 3,
"replyTo": "[email protected]",
"sslEnabled": true,
"tlsEnabled": false,
"username": "[email protected]"
},
"message": "SMTP ayarı kaydedildi.",
"success": true,
"timestamp": "2026-03-07T01:21:53.2632826"
}/api/mail/projects/{projectId}/smtp-configBir projeye ait kayıtlı SMTP ayarını getirir.
Headers
| İsim | Değer | Zorunlu |
|---|---|---|
| X-Internal-Service-Token | {{platformKey}} | Evet |
| X-Internal-Service-Name | AUTH-SERVICE | Evet |
Yanıt Örneği
{
"data": {
"active": true,
"fromEmail": "[email protected]",
"fromName": "EVDSOFT",
"host": "smtp.hostinger.com",
"id": 2,
"port": 465,
"projectId": 4,
"replyTo": "[email protected]",
"sslEnabled": true,
"tlsEnabled": false,
"username": "[email protected]"
},
"message": "SMTP ayarı getirildi.",
"success": true,
"timestamp": "2026-03-07T01:41:10.7092026"
}/api/mail/projects/smtp-config/testGirilen SMTP ayarlarını kalıcı kaydetmeden test eder ve test e-postası gönderir.
Headers
| İsim | Değer | Zorunlu |
|---|---|---|
| X-Internal-Service-Token | {{platformKey}} | Evet |
| X-Internal-Service-Name | AUTH-SERVICE | Evet |
| Content-Type | application/json | Evet |
İstek Örneği
{
"host": "smtp.hostinger.com",
"port": 465,
"username": "[email protected]",
"password": "your-password",
"fromEmail": "[email protected]",
"fromName": "EVDSOFT",
"replyTo": "[email protected]",
"toEmail": "[email protected]",
"sslEnabled": true,
"tlsEnabled": false
}Yanıt Örneği
{
"data": {
"connected": true,
"toEmail": "[email protected]",
"mailSent": true
},
"message": "SMTP bağlantısı doğrulandı ve test e-postası gönderildi.",
"success": true,
"timestamp": "2026-03-07T02:12:20.2851454"
}SMTP Test Hataları
- Yanlış host durumunda bağlantı hatası ve
UnknownHostExceptionbenzeri detay dönüyor. - Yanlış kullanıcı adı/şifre durumunda
Authentication failedmesajı dönüyor.
Template Yönetimi
/api/mail/projects/{projectId}/templatesBir projeye özel mail template kaydeder veya günceller.
Headers
| İsim | Değer | Zorunlu |
|---|---|---|
| X-Internal-Service-Token | {{platformKey}} | Evet |
| X-Internal-Service-Name | AUTH-SERVICE | Evet |
| Content-Type | application/json | Evet |
İstek Örneği
{
"code": "EMAIL_VERIFICATION",
"name": "E-Sentinel Doğrulama Maili",
"subjectTemplate": "Doğrulama kodun: {{code}}",
"bodyHtml": "<html><body><h2>E-Sentinel</h2><p>Merhaba {{userName}}</p><p>Kodun: <strong>{{code}}</strong></p></body></html>",
"bodyText": "Merhaba {{userName}}, kodun: {{code}}",
"active": true
}Yanıt Örneği
{
"data": {
"active": true,
"bodyHtml": "<html><body><h2>E-Sentinel</h2><p>Merhaba {{userName}}</p><p>Kodun: <strong>{{code}}</strong></p></body></html>",
"bodyText": "Merhaba {{userName}}, kodun: {{code}}",
"code": "EMAIL_VERIFICATION",
"createdAt": "2026-03-07T01:22:01.69338",
"defaultTemplate": false,
"id": 7,
"name": "E-Sentinel Doğrulama Maili",
"projectId": 3,
"subjectTemplate": "Doğrulama kodun: {{code}}",
"updatedAt": "2026-03-07T01:22:01.69338"
},
"message": "Template kaydedildi.",
"success": true,
"timestamp": "2026-03-07T01:22:22.4330281"
}/api/mail/projects/{projectId}/templatesDefault ve projeye özel template listesini getirir.
Headers
| İsim | Değer | Zorunlu |
|---|---|---|
| X-Internal-Service-Token | {{platformKey}} | Evet |
| X-Internal-Service-Name | AUTH-SERVICE | Evet |
Yanıt Örneği
{
"data": [
{
"active": true,
"code": "WELCOME",
"defaultTemplate": true,
"id": 1,
"name": "Default Welcome",
"projectId": null,
"subjectTemplate": "Hoş geldin {{userName}}"
},
{
"active": true,
"code": "EMAIL_VERIFICATION",
"defaultTemplate": true,
"id": 2,
"name": "Default Email Verification",
"projectId": null,
"subjectTemplate": "E-posta doğrulama kodun: {{code}}"
},
{
"active": true,
"code": "EMAIL_VERIFICATION",
"defaultTemplate": false,
"id": 8,
"name": "E-Sentinel Doğrulama Maili",
"projectId": 4,
"subjectTemplate": "Doğrulama kodun: {{code}}"
}
],
"message": "Template listesi getirildi.",
"success": true,
"timestamp": "2026-03-07T01:41:55.0000000"
}Default Template Yapısı
WELCOME, EMAIL_VERIFICATION,PASSWORD_RESET ve LOGIN_ALERT gibi sistem template'lerinin bulunduğu görülüyor.Mail Gönderimi
/api/mail/send/templateDomain üzerinden ilgili projeyi çözerek template tabanlı mail gönderir.
Headers
| İsim | Değer | Zorunlu |
|---|---|---|
| X-Internal-Service-Token | {{platformKey}} | Evet |
| X-Internal-Service-Name | AUTH-SERVICE | Evet |
| Content-Type | application/json | Evet |
İstek Örneği
{
"domain": "platform-dev.evdsoft.com",
"toEmail": "[email protected]",
"templateCode": "EMAIL_VERIFICATION",
"variables": {
"userName": "Engin",
"code": "482913",
"minutes": "10",
"projectName": "E-Sentinel"
}
}Yanıt Örneği
{
"data": {
"sent": true
},
"message": "Template e-postası gönderildi.",
"success": true,
"timestamp": "2026-03-07T01:36:19.2749612"
}/api/mail/send/rawHazır subject/bodyHtml/bodyText ile doğrudan e-posta gönderir.
Headers
| İsim | Değer | Zorunlu |
|---|---|---|
| X-Internal-Service-Token | {{platformKey}} | Evet |
| X-Internal-Service-Name | AUTH-SERVICE | Evet |
| Content-Type | application/json | Evet |
İstek Örneği
{
"domain": "platform-dev.evdsoft.com",
"toEmail": "[email protected]",
"subject": "Test mail",
"bodyHtml": "<html><body><h1>Selam</h1><p>Bu bir test mailidir.</p></body></html>",
"bodyText": "Selam, bu bir test mailidir."
}Yanıt Örneği
{
"data": {
"sent": true
},
"message": "E-posta gönderildi.",
"success": true,
"timestamp": "2026-03-07T01:40:04.7068226"
}/api/mail/send/test-templateBelirli bir projectId üzerinden template mailini test amaçlı gönderir.
Headers
| İsim | Değer | Zorunlu |
|---|---|---|
| X-Internal-Service-Token | {{platformKey}} | Evet |
| X-Internal-Service-Name | AUTH-SERVICE | Evet |
| Content-Type | application/json | Evet |
İstek Örneği
{
"projectId": 4,
"toEmail": "[email protected]",
"templateCode": "WELCOME",
"variables": {
"userName": "Engin",
"projectName": "E-Sentinel"
}
}Yanıt Örneği
{
"data": {
"sent": true
},
"message": "Test template e-postası gönderildi.",
"success": true,
"timestamp": "2026-03-07T01:40:37.1784268"
}Loglar
/api/mail/projects/{projectId}/logsBir projeye ait son mail gönderim loglarını getirir.
Headers
| İsim | Değer | Zorunlu |
|---|---|---|
| X-Internal-Service-Token | {{platformKey}} | Evet |
| X-Internal-Service-Name | AUTH-SERVICE | Evet |
Yanıt Örneği
{
"data": [
{
"createdAt": "2026-03-07T01:40:35.886267",
"errorMessage": null,
"id": 4,
"projectId": 4,
"providerType": "SMTP",
"sentAt": "2026-03-07T01:40:37.172722",
"status": "SENT",
"subject": "Hoş geldin Engin",
"templateCode": "WELCOME",
"toEmail": "[email protected]"
},
{
"createdAt": "2026-03-07T01:40:03.628662",
"errorMessage": null,
"id": 3,
"projectId": 4,
"providerType": "SMTP",
"sentAt": "2026-03-07T01:40:04.702197",
"status": "SENT",
"subject": "Test mail",
"templateCode": null,
"toEmail": "[email protected]"
}
],
"message": "Son loglar getirildi.",
"success": true,
"timestamp": "2026-03-07T01:41:35.682939"
}Veri Modelleri
Aşağıdaki tablolar, yüklediğin mail koleksiyonundaki gerçek response örneklerine göre hazırlanmıştır.
SMTP Config Şeması
| Alan | Tip | Açıklama |
|---|---|---|
| id | number | SMTP config kayıt ID değeri |
| projectId | number | İlgili proje ID değeri |
| host | string | SMTP sunucu adresi |
| port | number | SMTP port numarası |
| username | string | SMTP kullanıcı adı |
| fromEmail | string | Gönderici e-posta adresi |
| fromName | string | Gönderici görünen adı |
| replyTo | string | Yanıt e-posta adresi |
| sslEnabled | boolean | SSL aktif mi? |
| tlsEnabled | boolean | TLS aktif mi? |
| active | boolean | Config aktif mi? |
Template Şeması
| Alan | Tip | Açıklama |
|---|---|---|
| id | number | Template kayıt ID değeri |
| projectId | number | null | Projeye özel ise proje ID, default template ise null |
| code | string | Template benzersiz kodu |
| name | string | Template adı |
| subjectTemplate | string | Konu şablonu |
| bodyHtml | string | HTML mail içeriği |
| bodyText | string | Plain text mail içeriği |
| active | boolean | Template aktif mi? |
| defaultTemplate | boolean | Sistem default template mi? |
| createdAt | datetime | Oluşturulma tarihi |
| updatedAt | datetime | Güncellenme tarihi |
Mail Log Şeması
| Alan | Tip | Açıklama |
|---|---|---|
| id | number | Log kayıt ID değeri |
| projectId | number | İlgili proje ID değeri |
| providerType | string | Kullanılan gönderim sağlayıcısı, örn. SMTP |
| toEmail | string | Alıcı e-posta adresi |
| subject | string | Gönderilen e-postanın konusu |
| templateCode | string | null | Template ile gönderildiyse template kodu |
| status | string | Gönderim durumu, örn. SENT |
| errorMessage | string | null | Hata varsa hata mesajı |
| createdAt | datetime | Kayıt oluşturulma zamanı |
| sentAt | datetime | null | Gerçek gönderim zamanı |
Yanıt Standardı
Başarılı response gövdeleri tutarlı biçimde aşağıdaki alanları içeriyor:
| Alan | Tip | Açıklama |
|---|---|---|
| success | boolean | İşlemin başarılı olup olmadığını belirtir |
| message | string | İşleme ait kullanıcı dostu açıklama mesajı |
| data | object | array | null | Asıl yanıt yükü |
| timestamp | datetime | Yanıtın üretildiği zaman damgası |
Hata Response Yapısı
success: false,error,message,path,status vevalidationErrorsalanlarının döndüğü görülüyor.