amsom-habitat/mailer-sender
Composer 安装命令:
composer require amsom-habitat/mailer-sender
包简介
Utilities pour les envoies de mails depuis MailerInterface
README 文档
README
Petit connecteur PHP pour envoyer des mails via l'API mailing d'AMSOM Habitat.
Installation
composer require amsom-habitat/mailer-sender
Configuration (2 variables d'env)
API_MAIL_URL=http://api_mailing # base de l'API mailing
API_MAIL_KEY=ma_cle_api # clé fournie par l'API (route /v2)
La gestion prod / test (redirection des mails) est désormais assurée par l'API elle-même, plus par le connecteur.
Utilisation — send()
Une seule méthode, un tableau. On ajoute une option = on ajoute une clé.
use AmsomUtilities\MailerSender;
// $mailer est injecté par Symfony (autowiring)
$res = $mailer->send([
'template' => 'basic', // nom de template, 'custom' ou 'simple'
'to' => 'locataire@example.com',
'subject' => 'Information',
'body' => ['message' => 'Bonjour, votre demande a été prise en compte.'],
]);
if (!$res['success']) {
// $res['httpStatus'], $res['error']
}
// $res['id'] = identifiant de suivi (visible sur /emails de l'API)
Champs disponibles
💡 Découverte : le tableau
array{...}dans le docblock desend()→ PhpStorm autocomplète les clés. Pour une liste à l'exécution :dump(\AmsomUtilities\MailerSender::champsDisponibles()); // clé => description, à date
| Clé | Type | Description |
|---|---|---|
template | string | Requis. Nom de template (basic, enquete, …), custom ou simple |
to | string | string[] | Requis. Destinataire — un email ou un tableau d'emails |
subject | string | Requis. Objet |
body | array | Données du template |
text | string | Contenu brut (pour template: 'simple') |
from | string | Expéditeur réel (passe par le relay interne) |
replyTo | string | Adresse de réponse (en-tête Reply-To) |
cc / cci | string[] | Copies / copies cachées |
destinataire | string | Nom affiché du destinataire |
attachments | array[] | Pièces jointes (voir ci-dessous) |
options | array | Config de template libre : logo, bonjour, signature, … |
delivery | array | mode (async/sync), retries, delayMs, timeToKeep, testMode |
Pièces jointes
'attachments' => [
// contenu déjà en base64
['filename' => 'facture.pdf', 'content' => $base64],
// OU un fichier / une URL, converti en base64 par le connecteur
['filename' => 'photo.jpg', 'content' => '/tmp/photo.jpg', 'type' => 'path'],
['filename' => 'image', 'content' => 'https://…', 'type' => 'url'],
]
Exemple custom + expéditeur + réponse
$mailer->send([
'template' => 'custom',
'to' => 'locataire@example.com',
'subject' => 'Votre dossier',
'from' => 'service-client@amsom-habitat.fr',
'replyTo' => 'contact@amsom-habitat.fr',
'body' => ['message' => 'Veuillez trouver le document ci-joint.'],
'options' => ['logo' => 'logoSyneo', 'signature' => ['nom' => 'Martin', 'prenom' => 'Claire']],
'attachments' => [['filename' => 'dossier.pdf', 'content' => '/tmp/dossier.pdf', 'type' => 'path']],
'delivery' => ['mode' => 'sync'],
]);
Valeur de retour
send() renvoie un tableau : success (bool), httpStatus (int), id (hash de suivi), status, et error en cas d'échec. Lève \RuntimeException si la config manque ou si l'appel réseau échoue.
Anciennes méthodes (dépréciées)
sendMail(), apiSendMail() et apiSendMailCustom() restent disponibles à l'identique pour compatibilité, mais ne sont plus recommandées : préférez send().
amsom-habitat/mailer-sender 适用场景与选型建议
amsom-habitat/mailer-sender 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.46k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 04 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 amsom-habitat/mailer-sender 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 amsom-habitat/mailer-sender 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 amsom-habitat/mailer-sender 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This module allows drag & drop grouping of items in a GridField
Adds text size controls and text-to-speech controls to Flarum discussion content.
Native Blade date, datetime, and date range pickers.
Symfony and Flysystem integration for the maintained KCFinder continuation.
Laravel integration for the maintained KCFinder continuation.
PHPStan rules shared across KnpLabs organization projects
统计信息
- 总下载量: 12.46k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2023-04-20