{"id":13617017,"url":"https://github.com/symfony/mailer","last_synced_at":"2025-05-14T22:03:26.900Z","repository":{"id":37951853,"uuid":"178552393","full_name":"symfony/mailer","owner":"symfony","description":"Helps sending emails","archived":false,"fork":false,"pushed_at":"2025-05-02T09:22:07.000Z","size":774,"stargazers_count":1553,"open_issues_count":0,"forks_count":50,"subscribers_count":14,"default_branch":"7.2","last_synced_at":"2025-05-07T00:15:48.791Z","etag":null,"topics":["component","php","symfony","symfony-component"],"latest_commit_sha":null,"homepage":"https://symfony.com/mailer","language":"PHP","has_issues":false,"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/symfony.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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},"funding":{"github":"fabpot","tidelift":"packagist/symfony/symfony","custom":"https://symfony.com/sponsor"}},"created_at":"2019-03-30T11:54:41.000Z","updated_at":"2025-05-06T08:15:11.000Z","dependencies_parsed_at":"2024-01-02T10:56:42.794Z","dependency_job_id":"30e69488-dc45-41c1-8d8e-718cccba1b56","html_url":"https://github.com/symfony/mailer","commit_stats":{"total_commits":385,"total_committers":100,"mean_commits":3.85,"dds":0.7168831168831169,"last_synced_commit":"e4d358702fb66e4c8a2af08e90e7271a62de39cc"},"previous_names":[],"tags_count":224,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/symfony%2Fmailer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/symfony%2Fmailer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/symfony%2Fmailer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/symfony%2Fmailer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/symfony","download_url":"https://codeload.github.com/symfony/mailer/tar.gz/refs/heads/7.2","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252841315,"owners_count":21812449,"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":["component","php","symfony","symfony-component"],"created_at":"2024-08-01T20:01:35.922Z","updated_at":"2025-05-07T08:26:34.842Z","avatar_url":"https://github.com/symfony.png","language":"PHP","funding_links":["https://github.com/sponsors/fabpot","https://tidelift.com/funding/github/packagist/symfony/symfony","https://symfony.com/sponsor"],"categories":["Table of Contents","PHP","目录"],"sub_categories":["Email","电子邮件 Email","Library"],"readme":"Mailer Component\n================\n\nThe Mailer component helps sending emails.\n\nGetting Started\n---------------\n\n```bash\ncomposer require symfony/mailer\n```\n\n```php\nuse Symfony\\Component\\Mailer\\Transport;\nuse Symfony\\Component\\Mailer\\Mailer;\nuse Symfony\\Component\\Mime\\Email;\n\n$transport = Transport::fromDsn('smtp://localhost');\n$mailer = new Mailer($transport);\n\n$email = (new Email())\n    -\u003efrom('hello@example.com')\n    -\u003eto('you@example.com')\n    //-\u003ecc('cc@example.com')\n    //-\u003ebcc('bcc@example.com')\n    //-\u003ereplyTo('fabien@example.com')\n    //-\u003epriority(Email::PRIORITY_HIGH)\n    -\u003esubject('Time for Symfony Mailer!')\n    -\u003etext('Sending emails is fun again!')\n    -\u003ehtml('\u003cp\u003eSee Twig integration for better HTML integration!\u003c/p\u003e');\n\n$mailer-\u003esend($email);\n```\n\nTo enable the Twig integration of the Mailer, require `symfony/twig-bridge` and\nset up the `BodyRenderer`:\n\n```php\nuse Symfony\\Bridge\\Twig\\Mime\\BodyRenderer;\nuse Symfony\\Bridge\\Twig\\Mime\\TemplatedEmail;\nuse Symfony\\Component\\EventDispatcher\\EventDispatcher;\nuse Symfony\\Component\\Mailer\\EventListener\\MessageListener;\nuse Symfony\\Component\\Mailer\\Mailer;\nuse Symfony\\Component\\Mailer\\Transport;\nuse Twig\\Environment as TwigEnvironment;\n\n$twig = new TwigEnvironment(...);\n$messageListener = new MessageListener(null, new BodyRenderer($twig));\n\n$eventDispatcher = new EventDispatcher();\n$eventDispatcher-\u003eaddSubscriber($messageListener);\n\n$transport = Transport::fromDsn('smtp://localhost', $eventDispatcher);\n$mailer = new Mailer($transport, null, $eventDispatcher);\n\n$email = (new TemplatedEmail())\n    // ...\n    -\u003ehtmlTemplate('emails/signup.html.twig')\n    -\u003econtext([\n        'expiration_date' =\u003e new \\DateTimeImmutable('+7 days'),\n        'username' =\u003e 'foo',\n    ])\n;\n$mailer-\u003esend($email);\n```\n\nSponsor\n-------\n\nThe Mailer component for Symfony 7.2 is [backed][1] by:\n\n * [Sweego][2], a European email and SMS sending platform for developers and product builders. Easily create, deliver, and monitor your emails and notifications.\n\nHelp Symfony by [sponsoring][3] its development!\n\nResources\n---------\n\n * [Documentation](https://symfony.com/doc/current/mailer.html)\n * [Contributing](https://symfony.com/doc/current/contributing/index.html)\n * [Report issues](https://github.com/symfony/symfony/issues) and\n   [send Pull Requests](https://github.com/symfony/symfony/pulls)\n   in the [main Symfony repository](https://github.com/symfony/symfony)\n\n[1]: https://symfony.com/backers\n[2]: https://www.sweego.io/\n[3]: https://symfony.com/sponsor\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsymfony%2Fmailer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsymfony%2Fmailer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsymfony%2Fmailer/lists"}