{"id":21152092,"url":"https://github.com/mailjet/mailjetswiftmailer","last_synced_at":"2025-07-09T09:32:24.963Z","repository":{"id":57079822,"uuid":"93388436","full_name":"mailjet/MailjetSwiftMailer","owner":"mailjet","description":"A SwiftMailer transport implementation for Mailjet","archived":false,"fork":false,"pushed_at":"2021-08-12T12:13:51.000Z","size":58,"stargazers_count":25,"open_issues_count":16,"forks_count":22,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-06-24T17:58:13.441Z","etag":null,"topics":["mailjet","mailjet-api","packagist","php","swiftmailer","swiftmailer-transport","symfony"],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/mailjet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-05T09:36:19.000Z","updated_at":"2025-04-27T13:41:10.000Z","dependencies_parsed_at":"2022-08-24T13:10:32.454Z","dependency_job_id":null,"html_url":"https://github.com/mailjet/MailjetSwiftMailer","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/mailjet/MailjetSwiftMailer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mailjet%2FMailjetSwiftMailer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mailjet%2FMailjetSwiftMailer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mailjet%2FMailjetSwiftMailer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mailjet%2FMailjetSwiftMailer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mailjet","download_url":"https://codeload.github.com/mailjet/MailjetSwiftMailer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mailjet%2FMailjetSwiftMailer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264431163,"owners_count":23607192,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["mailjet","mailjet-api","packagist","php","swiftmailer","swiftmailer-transport","symfony"],"created_at":"2024-11-20T10:24:22.267Z","updated_at":"2025-07-09T09:32:24.623Z","avatar_url":"https://github.com/mailjet.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MailjetSwiftMailer\n\n[![Build Status](https://travis-ci.org/mailjet/MailjetSwiftMailer.svg?branch=master)](https://travis-ci.org/mailjet/MailjetSwiftMailer)\n[![Packagist](https://img.shields.io/packagist/v/mailjet/mailjet-swiftmailer.svg)](https://packagist.org/packages/mailjet/mailjet-swiftmailer)\n[![Packagist](https://img.shields.io/packagist/dt/mailjet/mailjet-swiftmailer.svg)](https://packagist.org/packages/mailjet/mailjet-swiftmailer)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/mailjet/MailjetSwiftMailer/blob/master/LICENSE.md)\n\nA SwiftMailer transport implementation for Mailjet\n([NEW] we now support send API v3.1 )\n[Mailjet Send API v3.1](https://dev.mailjet.com/guides/#send-api-v3-1-beta)\n*Compatible Mailjet send API V3 and V3.1*\n\nIf you found any problem, feel free to open an issue!\n\n## TODO\n\n* Adding URL tags\n* Sandbox Mode\n* Improve unit-tests (lots of code duplications)\n\n## Installation\n\nRequire the package with composer\n\n```bash\ncomposer require mailjet/mailjet-swiftmailer\n```\n\n## Usage Example\n\n```php\n$transport = new MailjetTransport($dispatchEvent, $apiKey, $apiSecret);\n$transport-\u003esetClientOptions(['url' =\u003e \"api.mailjet.com\", 'version' =\u003e 'v3.1', 'call' =\u003e true]);\n\n\n$transport-\u003esend($message);\n```\n\n\n(Send API v3 is selected by default)\n## Mailjet client custom configuration\n\nYou can pass an array in transport's constructor or use `setClientOptions` function:\n\n```php\n$clientOptions = ['url' =\u003e \"api.mailjet.com\", 'version' =\u003e 'v3.1', 'call' =\u003e false];\n$transport = new MailjetTransport($dispatchEvent, $apiKey, $apiSecret, $clientOptions);\n\n\nor\n\n$transport-\u003esetClientOptions(['url' =\u003e \"api.mailjet.com\", 'version' =\u003e 'v3.1', 'call' =\u003e true]);\n```\n\nProperties of $options:\n\n* url (Default: api.mailjet.com) : domain name of the API\n* version (Default: v3) : API version (only working for Mailjet API V3 +)\n* call (Default: true) : turns on(true) / off the call to the API\n* secured (Default: true) : turns on(true) / off the use of 'https'\n\n## Mailjet custom headers\n\nIt is possible to set specific Mailjet headers or custom user-defined headers, through SwiftMailer. \n\nFor example:\n\n```php\n$headers = $message-\u003egetHeaders();\n\n$headers-\u003eaddTextHeader('X-MJ-TemplateID', $templateId);\n$headers-\u003eaddTextHeader('X-MJ-TemplateLanguage', true);\n$vars = array(\"myFirstVar\" =\u003e \"foo\", \"mySecondVar\" =\u003e \"bar\");\n$headers-\u003eaddTextHeader('X-MJ-Vars', json_encode($vars));\n```\n\nNote: You need to `json_encode`your array of variables in order to be compatible with SMTP transport. \n\n* [Mailjet Email Headers documentation v3](https://dev.mailjet.com/guides/#send-api-json-properties)\n* [Mailjet Email Headers documentation v3.1](https://dev.mailjet.com/guides/#adding-email-headers)\n\n## Mailjet bulk sending\n\n```php\n\n$emails = ['f001@bar.com', 'f002@bar.com', 'f003@bar.com', 'f004@bar.com', 'f005@bar.com', 'f006@bar.com', ...]\n\n$messages = [];\nforeach ($emails as $email) {\n    $message = new \\Swift_Message('Test Subject', '\u003cp\u003eFoo bar\u003c/p\u003e', 'text/html');\n    $message\n        -\u003eaddTo($email)\n        -\u003eaddFrom('from@example.com', 'From Name')\n        -\u003eaddReplyTo('reply-to@example.com', 'Reply To Name')\n    ;\n\n    array_push($messages, $message);\n}\n$transport = new MailjetTransport($dispatchEvent, $apiKey, $apiSecret);\n$result = $transport-\u003ebulkSend($messages);\n\n```\n\nNote: does not work with Spool (SwiftMailer removed bulkSend from its API).\n\n## Integration in Symfony\n\nIf you want to use MailjetTransport in your Symfony project follow these small steps:\n\n1. `composer require mailjet/mailjet-swiftmailer`\n2. Into your `services.yml`, register MailjetTransport:\n\n```yaml\nswiftmailer.mailer.transport.mailjet:\n    class: Mailjet\\MailjetSwiftMailer\\SwiftMailer\\MailjetTransport\n    arguments:\n        - \"@swiftmailer.transport.eventdispatcher.mailjet\"\n        - \"%mailjet.api_key%\"\n        - \"%mailjet.secret_key%\"\n```\n\nNote: We set `mailjet.api_key` and `mailjet.secret_key` into parameters.yml\n\n3. Finally, configure SwiftMailer in your `config.yml`:\n\n```yaml\n# Swiftmailer Configuration\nswiftmailer:\n    transport: mailjet\n```\n\nNote: You can also inject your own `Mailjet\\Client`:\n\n```yaml\nmailjet.transactionnal.client:\n    class: \"%mailjet.client.class%\"\n    arguments:\n        - \"%mailjet.api_key%\"\n        - \"%mailjet.secret_key%\"\n        - %mailjet.transactionnal.call%\n        - %mailjet.transactionnal.options%\n\nswiftmailer.transport.eventdispatcher.mailjet:\n    class: Swift_Events_SimpleEventDispatcher\n\nswiftmailer.mailer.transport.mailjet:\n    class: Mailjet\\MailjetSwiftMailer\\SwiftMailer\\MailjetTransport\n    arguments:\n        - \"@swiftmailer.transport.eventdispatcher.mailjet\"\n        - \"%mailjet.api_key%\"\n        - \"%mailjet.secret_key%\"\n        - %mailjet.transactionnal.call%\n        - %mailjet.transactionnal.options%\n    calls:\n        - method: setExternalMailjetClient\n          arguments:\n              - '@mailjet.transactionnal.client'\n```\n\n## Mailjet references\n\n* [Mailjet PHP Wrapper](https://github.com/mailjet/mailjet-apiv3-php)\n* [Mailjet documentation v3: send transactional email](https://dev.mailjet.com/guides/#send-transactional-email)\n* [Mailjet documentation v3.1: send transactional email](https://dev.mailjet.com/beta/#send-transactional-email)\n\n## Execute Tests\n\n```bash\nvendor/bin/phpunit -c .\n```\n\n## Contributing\n\nIf you want to contribute to this project, look at [over here](CONTRIBUTING.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmailjet%2Fmailjetswiftmailer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmailjet%2Fmailjetswiftmailer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmailjet%2Fmailjetswiftmailer/lists"}