DEV Community

Cover image for كيفية تثبيت واستخدام Resend CLI
Yusuf Khalidd
Yusuf Khalidd

Posted on • Originally published at apidog.com

كيفية تثبيت واستخدام Resend CLI

أداة سطر الأوامر (CLI) الخاصة بـ Resend هي الأداة الرسمية لـ Resend، منصة بريد إلكتروني موجهة للمطورين. تتيح لك الأداة إرسال رسائل البريد الإلكتروني، إدارة النطاقات، وأتمتة البنية التحتية للبريد الإلكتروني من أي طرفية أو خط أنابيب CI/CD. التثبيت يتم عبر npm install -g resend-cli أو brew install resend/cli/resend، ثم المصادقة عبر resend login.

جرّب Apidog اليوم

ما هو Resend؟

Resend عبارة عن واجهة برمجة تطبيقات للبريد الإلكتروني مصممة للمطورين. اربط نطاقك، احصل على مفتاح API، وابدأ بإرسال رسائل البريد الإلكتروني للمعاملات (مثل: إعادة تعيين كلمة المرور، تأكيد الطلب، وغيرها) مباشرة من تطبيقك.

أداة Resend CLI أُطلقت في 13 مارس 2026، وتوفر 53 أمرًا عبر 13 موردًا رئيسيًا. الأداة مفتوحة المصدر (MIT)، ومكتوبة بـ TypeScript، وتستهدف:

  • المطورين: أوامر تفاعلية، جداول، جدولة باستخدام لغة طبيعية.
  • وكلاء الذكاء الاصطناعي: إخراج JSON، تحكم في التكرار والكشف التلقائي.
  • CI/CD: مصادقة عبر متغيرات البيئة، رموز خروج متسقة.

💡إذا كنت تطور تطبيقات ترسل بريدًا إلكترونيًا، ستحتاج لاختبار نقاط نهاية واجهة برمجة التطبيقات قبل الإنتاج. Apidog يوفر لك واجهة مرئية مجانية لاختبار REST API مثل Resend دون الحاجة لكتابة كود. يمكنك استيراد مواصفات OpenAPI، ضبط البيئات، وتشغيل اختبارات منظمة بسهولة.

تثبيت Resend CLI

اختر طريقة التثبيت الأنسب لبيئتك:

عبر cURL (ملف ثنائي مستقل، لا يتطلب Node.js)

curl -fsSL https://resend.com/install.sh | bash

ينزّل ملف ثنائي مناسب لنظامك ويضيفه إلى PATH. لا حاجة لـ Node.js.

عبر npm

npm install -g resend-cli

يتطلب Node.js 20+. تحقق من التثبيت:

resend --version

عبر Homebrew (macOS وLinux)

brew install resend/cli/resend

حل سريع على macOS مع تحديثات تلقائية.

عبر PowerShell (ويندوز)

irm https://resend.com/install.ps1 | iex

يمكنك أيضًا تنزيل ملف .exe مباشرة من GitHub Releases.

للتطوير المحلي

git clone https://github.com/resend/resend-cli.git
cd resend-cli
pnpm install
pnpm build       # ينتج ./dist/cli.cjs
pnpm build:bin   # ملف ثنائي محلي في ./dist/resend

مصادقة حسابك

شغل الأمر التالي لربط CLI بحسابك:

resend login

سيفتح المتصفح لإنشاء مفتاح API وتخزينه محليًا في ~/.config/resend/credentials.json (صلاحيات 0600).

للسكريبتات وCI/CD، يمكنك تمرير المفتاح مباشرة:

resend login --key re_xxxxxxxxxxxxx

ترتيب أولوية حل مفتاح API:

  1. --api-key (أولوية قصوى)
  2. RESEND_API_KEY كمتغير بيئة
  3. ملف بيانات الاعتماد المحلي

في خطوط CI/CD، استخدم:

RESEND_API_KEY=re_xxx resend emails send --from builds@yourco.com --to dev@yourco.com --subject "Build passed" --text "All tests green."

دعم الحسابات المتعددة

للتبديل بين الملفات الشخصية:

resend auth switch

أو مرر ملف شخصي لأمر واحد:

resend <command> --profile production

إرسال أول بريد إلكتروني

الأمر الرئيسي للإرسال:

resend emails send --from "you@yourdomain.com" --to recipient@example.com --subject "Hello from the CLI" --text "This is a test email sent from the Resend CLI."

إرسال نص عادي

resend emails send \
  --from "you@yourdomain.com" \
  --to recipient@example.com \
  --subject "Hello from the CLI" \
  --text "This is a test email sent from the Resend CLI."

إرسال HTML

resend emails send \
  --from "team@yourco.com" \
  --to user@example.com \
  --subject "Your order is confirmed" \
  --html "<h1>Order confirmed</h1><p>Thanks for your purchase.</p>"

أو من ملف محلي:

resend emails send \
  --from "team@yourco.com" \
  --to user@example.com \
  --subject "Welcome aboard" \
  --html-file ./templates/welcome.html

جدولة التسليم

resend emails send \
  --from "you@yourco.com" \
  --to user@example.com \
  --subject "Scheduled check-in" \
  --text "Just checking in." \
  --schedule "tomorrow at 9am"

يدعم عبارات مثل "بعد ساعة"، "الاثنين القادم 3 عصرًا"، أو ISO 8601.

التقاط معرف البريد

EMAIL_ID=$(resend emails send \
  --from a@acme.com \
  --to b@acme.com \
  --subject "Test" \
  --text "Hi" | jq -r '.data.id')
echo "Sent email: $EMAIL_ID"

إلغاء أو تحديث بريد مجدول

resend emails cancel $EMAIL_ID
resend emails update $EMAIL_ID --schedule "next Monday at 10am"

عرض الرسائل الأخيرة

resend emails list

إرسال دفعة (حتى 100 رسالة)

أنشئ ملف JSON:

[
  { "from": "you@yourco.com", "to": "alice@example.com", "subject": "Hi Alice", "text": "Hello!" },
  { "from": "you@yourco.com", "to": "bob@example.com", "subject": "Hi Bob", "text": "Hello!" }
]
resend emails send-batch --file emails.json

إدارة النطاقات ومفاتيح API

إضافة نطاق

resend domains create --name yourdomain.com --region us-east-1

المناطق: us-east-1، eu-west-1، sa-east-1، ap-northeast-1.

التحقق من سجلات DNS

resend domains verify --id <domain-id>
resend domains get --id <domain-id>

تكوين التتبع وTLS

resend domains configure --id <domain-id>

يمكنك تفعيل تتبع الفتح/النقر وDKIM مخصص.

عرض كل النطاقات

resend domains list

إدارة مفاتيح API

resend api-keys create
resend api-keys list
resend api-keys delete --id <key-id>

أوصى بإنشاء مفتاح مخصص لكل بيئة أو تكامل.

ميزات متقدمة: البث، Webhooks، القوالب

البث

resend broadcasts create
resend broadcasts send --id <broadcast-id>
resend broadcasts schedule --id <broadcast-id> --date "next Monday at 10am"

Webhooks

resend webhooks create
resend webhooks list
resend webhooks listen --forward-to http://localhost:3000/webhooks/resend

يدعم تلقي 17 نوع حدث، بما فيها: email.sent, email.delivered, email.bounced, email.opened, email.clicked.

القوالب

resend templates create

اعتمد متغيرات {{variable_name}} داخل HTML القالب.

جهات الاتصال والجمهور

resend contacts create --audience-id <id> --email user@example.com --first-name "Alice"
resend contacts list --audience-id <id>
resend contacts update --id <contact-id> --unsubscribed false

تشخيص البيئة

resend doctor

يُشخّص إصدار CLI، مفتاح API، حالة النطاقات، ويرصد بيئة التطوير.

تشغيل Resend CLI في CI/CD

إخراج آلي (JSON)

resend emails send --from a@co.com --to b@co.com --subject "Deploy" --text "Done" --json

العلامة --quiet لكتم الإخراج غير الهام:

resend emails list --quiet | jq '.[0].id'

تخطي التأكيدات التفاعلية

resend api-keys delete --id <key-id> --yes

مثال GitHub Actions

- name: Send deployment notification
  env:
    RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }}
  run: |
    resend emails send \
      --from deploys@yourco.com \
      --to team@yourco.com \
      --subject "Deploy to production: ${{ github.sha }}" \
      --text "Deployed commit ${{ github.sha }} to production."

حدود المعدل

الحد: طلبان/ثانية لكل فريق. استخدم send-batch للدفعات بدلًا من الحلقات المتكررة.

اختبار REST API للبريد الإلكتروني باستخدام Apidog

Resend CLI فعالة للاستخدام التفاعلي والسكريبتات، لكن لاختبار نقاط النهاية مباشرةً أثناء تطوير الخلفية، استخدم Apidog:

  • استيراد مواصفات Resend API: استورد OpenAPI من resend.com/docs إلى Apidog لمشاهدة كل نقطة نهاية.
  • إعداد بيئات: أنشئ بيئة dev/production وخزن RESEND_API_KEY كمتغير.
  • اختبار طلب الإرسال: شغل POST /emails في Apidog، تحقق من الاستجابة والمعرف.
  • أتمتة الاختبارات: اربط استدعاءات API في Apidog وتحقق من النتائج دون كود اختبار يدوي.

هذه الطريقة تقلل أخطاء التكامل قبل الإنتاج، وتكمل استخدام CLI محليًا.

تسعير Resend

أداة CLI مجانية ومفتوحة المصدر. التسعير ينطبق على منصة Resend فقط:

الخطة السعر رسائل بريد إلكتروني شهرية الحد اليومي مدة الاحتفاظ بالسجلات
مجاني 0 دولار/الشهر 3,000 100/اليوم يوم واحد
احترافي 20 دولار/الشهر 50,000 بلا حدود 3 أيام
توسع 90 دولار/الشهر 100,000 بلا حدود 7 أيام
مؤسسي مخصص مخصص م

Top comments (0)