{"id":21623024,"url":"https://github.com/pandatecham/be-lib-communicator","last_synced_at":"2026-04-13T20:04:26.622Z","repository":{"id":219792450,"uuid":"749939160","full_name":"PandaTechAM/be-lib-communicator","owner":"PandaTechAM","description":"A versatile .NET library for integrating SMS and email functionalities. Supports multiple SMS providers and easy configuration through appsettings.json or web builders, ideal for efficient and reliable messaging in any application.","archived":false,"fork":false,"pushed_at":"2026-03-09T09:01:41.000Z","size":244,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"development","last_synced_at":"2026-03-09T13:25:49.266Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PandaTechAM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-01-29T17:32:04.000Z","updated_at":"2026-03-09T09:00:56.000Z","dependencies_parsed_at":"2024-03-19T12:25:34.502Z","dependency_job_id":"d3f18921-9f2c-4080-ab2c-d0bd773e633c","html_url":"https://github.com/PandaTechAM/be-lib-communicator","commit_stats":null,"previous_names":["pandatecham/be-lib-communicator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PandaTechAM/be-lib-communicator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PandaTechAM%2Fbe-lib-communicator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PandaTechAM%2Fbe-lib-communicator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PandaTechAM%2Fbe-lib-communicator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PandaTechAM%2Fbe-lib-communicator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PandaTechAM","download_url":"https://codeload.github.com/PandaTechAM/be-lib-communicator/tar.gz/refs/heads/development","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PandaTechAM%2Fbe-lib-communicator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31768705,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T15:25:13.801Z","status":"ssl_error","status_checked_at":"2026-04-13T15:25:09.162Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-25T00:11:17.296Z","updated_at":"2026-04-13T20:04:26.616Z","avatar_url":"https://github.com/PandaTechAM.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pandatech.Communicator\n\nSend email via SMTP and SMS via Dexatel or Twilio through a DI-friendly, multi-channel API. Supports both\n`appsettings.json` and programmatic configuration, named channels per transport, and a fake mode for local development.\n\nTargets **`net8.0`**, **`net9.0`**, and **`net10.0`**.\n\n---\n\n## Table of Contents\n\n1. [Features](#features)\n2. [Installation](#installation)\n3. [Registration](#registration)\n4. [Configuration](#configuration)\n5. [Channels](#channels)\n6. [Sending Email](#sending-email)\n7. [Sending SMS](#sending-sms)\n8. [Fake Mode](#fake-mode)\n\n---\n\n## Features\n\n- Email over SMTP using MailKit — TLS negotiation, optional authentication, CC/BCC, attachments, HTML body\n- SMS via Dexatel and Twilio with a unified `GeneralSmsResponse`\n- Named channels — configure multiple senders per transport (e.g. `TransactionalSender`, `MarketingSender`) and pick\n  the right one per message\n- Validation on every send call — recipients, addresses, and phone numbers are checked before any network call\n- Fake mode — logs messages at `Critical` instead of sending; zero external calls in development or test environments\n- Supports both `WebApplicationBuilder` and plain `IServiceCollection` registration\n\n---\n\n## Installation\n\n```bash\ndotnet add package Pandatech.Communicator\n```\n\n---\n\n## Registration\n\n### WebApplicationBuilder\n\n```csharp\nbuilder.AddCommunicator();           // reads from appsettings.json \"Communicator\" section\n// or\nbuilder.AddCommunicator(options =\u003e { /* programmatic setup */ });\n```\n\n### IServiceCollection\n\n```csharp\nservices.AddCommunicator(configuration);\n// or\nservices.AddCommunicator(configuration, options =\u003e { /* programmatic setup */ });\n```\n\nBoth register `IEmailService` and `ISmsService` into DI as scoped services.\n\n---\n\n## Configuration\n\n### appsettings.json\n\n```json\n{\n  \"Communicator\": {\n    \"EmailFake\": false,\n    \"SmsFake\": false,\n    \"EmailConfigurations\": {\n      \"TransactionalSender\": {\n        \"SmtpServer\": \"smtp.gmail.com\",\n        \"SmtpPort\": 587,\n        \"SmtpUsername\": \"you@example.com\",\n        \"SmtpPassword\": \"app-password\",\n        \"SenderEmail\": \"no-reply@example.com\",\n        \"SenderName\": \"My App\",\n        \"TimeoutMs\": 10000\n      },\n      \"MarketingSender\": {\n        \"SmtpServer\": \"smtp.sendgrid.net\",\n        \"SmtpPort\": 587,\n        \"SmtpUsername\": \"apikey\",\n        \"SmtpPassword\": \"SG.xxx\",\n        \"SenderEmail\": \"marketing@example.com\",\n        \"TimeoutMs\": 10000\n      }\n    },\n    \"SmsConfigurations\": {\n      \"TransactionalSender\": {\n        \"Provider\": \"Dexatel\",\n        \"From\": \"MyApp\",\n        \"TimeoutMs\": 10000,\n        \"Properties\": {\n          \"X-Dexatel-Key\": \"your-dexatel-api-key\"\n        }\n      },\n      \"NotificationSender\": {\n        \"Provider\": \"Twilio\",\n        \"From\": \"+15550001234\",\n        \"TimeoutMs\": 10000,\n        \"Properties\": {\n          \"SID\": \"ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\n          \"AUTH_TOKEN\": \"your-auth-token\"\n        }\n      }\n    }\n  }\n}\n```\n\n### Programmatic\n\n```csharp\nbuilder.AddCommunicator(options =\u003e\n{\n    options.EmailConfigurations = new Dictionary\u003cstring, EmailConfiguration\u003e\n    {\n        [\"TransactionalSender\"] = new()\n        {\n            SmtpServer   = \"smtp.gmail.com\",\n            SmtpPort     = 587,\n            SmtpUsername = \"you@example.com\",\n            SmtpPassword = \"app-password\",\n            SenderEmail  = \"no-reply@example.com\",\n            SenderName   = \"My App\"\n        }\n    };\n\n    options.SmsConfigurations = new Dictionary\u003cstring, SmsConfiguration\u003e\n    {\n        [\"TransactionalSender\"] = new()\n        {\n            Provider = \"Dexatel\",\n            From     = \"MyApp\",\n            Properties = new() { [\"X-Dexatel-Key\"] = \"your-key\" }\n        }\n    };\n});\n```\n\n---\n\n## Channels\n\nChannel names are validated at startup against a fixed set of supported names:\n\n```\nGeneralSender\nTransactionalSender\nNotificationSender\nMarketingSender\nSupportSender\n```\n\nEach channel maps to exactly one configuration entry. The `Channel` property on `EmailMessage` and `SmsMessage`\nselects which configuration is used for that send call.\n\n---\n\n## Sending Email\n\n```csharp\npublic class NotificationService(IEmailService emailService)\n{\n    public async Task SendWelcomeAsync(string userEmail, CancellationToken ct)\n    {\n        var message = new EmailMessage\n        {\n            Recipients  = [userEmail],\n            Subject     = \"Welcome!\",\n            Body        = \"\u003ch1\u003eThanks for signing up.\u003c/h1\u003e\",\n            IsBodyHtml  = true,\n            Channel     = EmailChannels.TransactionalSender,\n            Cc          = [\"manager@example.com\"],\n            Attachments = [new EmailAttachment(\"terms.pdf\", pdfBytes)]\n        };\n\n        var response = await emailService.SendAsync(message, ct);\n    }\n}\n```\n\n`SendBulkAsync` accepts a list of messages, opens one SMTP connection per channel, and sends all messages for that\nchannel on the same connection before moving to the next.\n\n---\n\n## Sending SMS\n\n```csharp\npublic class OtpService(ISmsService smsService)\n{\n    public async Task SendOtpAsync(string phoneNumber, string code, CancellationToken ct)\n    {\n        var message = new SmsMessage\n        {\n            Recipients = [phoneNumber],\n            Message    = $\"Your code is {code}\",\n            Channel    = SmsChannels.TransactionalSender\n        };\n\n        var responses = await smsService.SendAsync(message, ct);\n    }\n}\n```\n\nPhone numbers are normalized before sending — `+`, `(`, `)`, and spaces are stripped, and Panda-formatted numbers\nlike `(374)91123456` are handled automatically.\n\n### Provider-specific Properties\n\n| Provider  | Required Properties              |\n|-----------|----------------------------------|\n| Dexatel   | `X-Dexatel-Key`                  |\n| Twilio    | `SID`, `AUTH_TOKEN`              |\n\n---\n\n## Fake Mode\n\nSet `EmailFake: true` or `SmsFake: true` (or both) to replace the real services with fake implementations that log\nat `Critical` instead of making any network calls. The same validation still runs.\n\n```json\n{\n  \"Communicator\": {\n    \"EmailFake\": true,\n    \"SmsFake\": true\n  }\n}\n```\n\nUseful in local development and CI environments where you want to confirm messages are being sent without delivering\nthem.\n\n---\n\n## License\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpandatecham%2Fbe-lib-communicator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpandatecham%2Fbe-lib-communicator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpandatecham%2Fbe-lib-communicator/lists"}