تكوين SMTP البريد للمشروع
يمكن لكل مشروع Jambo أن يكون له خادم SMTP خاص به. يتم استخدام البريد لإرسال الرسائل (نماذج الاتصال، إعادة تعيين كلمة المرور، إلخ). يتم تشفير كلمة المرور على الخادم باستخدام XSalsa20-Poly1305.
GET /api/projects/{projectUuid}/settings/mailerPUT /api/projects/{projectUuid}/settings/mailerPOST /api/projects/{projectUuid}/settings/mailer/testالمصادقة
يتطلب إما:
- جلسة مسؤول صالحة (للوحة الإدارة)
- رمز API مع صلاحية
create
Authorization: Bearer TOKEN_APIGET — قراءة تكوين SMTP
curl https://your-domain.com/api/projects/{projectUuid}/settings/mailer \ -H "Authorization: Bearer TOKEN_API"الاستجابة (مُكوّن)
{ "data": { "host": "smtp.resend.com", "port": 587, "username": "resend", "encryption": "tls", "from_email": "noreply@example.com", "from_name": "مشروعي", "enabled": true }}PUT — إنشاء أو تعديل تكوين SMTP
curl -X PUT https://your-domain.com/api/projects/{projectUuid}/settings/mailer \ -H "Authorization: Bearer TOKEN_API" \ -H "Content-Type: application/json" \ -d '{ "host": "smtp.gmail.com", "port": 587, "username": "apikey", "password": "كلمة-المرور", "encryption": "tls", "from_email": "noreply@example.com", "from_name": "مشروعي", "enabled": true }'| الحقل | النوع | مطلوب | الوصف |
|---|---|---|---|
host | string | لا | مضيف SMTP (متحقق: لا IP خاص) |
port | integer | لا | منفذ SMTP. مسموح: 25, 465, 587, 2525 |
username | string | لا | اسم المستخدم SMTP |
password | string | لا | كلمة مرور SMTP (مشفرة عند التخزين) |
encryption | string | لا | tls, ssl, أو none |
from_email | string | لا | بريد المرسل |
from_name | string | لا | اسم المرسل |
enabled | boolean | لا | تفعيل أو تعطيل البريد |
POST — إرسال بريد تجريبي
curl -X POST https://your-domain.com/api/projects/{projectUuid}/settings/mailer/test \ -H "Authorization: Bearer TOKEN_API"الاستجابة (نجاح)
{ "sent": true }الاستجابة (فشل)
{ "error": "فشل الإرسال. تحقق من تكوين SMTP." }رموز الحالة
| الحالة | الوصف |
|---|---|
200 | تمت القراءة أو التعديل بنجاح |
400 | مضيف غير صالح أو منفذ غير صالح |
403 | تم رفض الوصول |
404 | المشروع غير موجود |
422 | البريد غير مُكوّن أو معطل |
الإرسال البرمجي
use App\Service\ProjectMailerService;use App\Message\Attachment;
$mailerService->send( project: $project, to: 'client@example.com', subject: 'مرحباً!', body: 'نص احتياطي', htmlBody: '<h1>مرحباً!</h1><p>شكراً لتسجيلك.</p>', replyTo: 'support@example.com', cc: ['manager@example.com'], bcc: ['archive@example.com'], attachments: [ new Attachment( content: file_get_contents('/path/report.pdf'), filename: 'تقرير_شهري.pdf', mimeType: 'application/pdf', ), ],);يتم إرسال الرسائل بشكل غير متزامن عبر Symfony Messenger وتسجيلها في جدول email_log.