{"id":23107933,"url":"https://github.com/andrewdyer/slim3-mailer","last_synced_at":"2025-10-10T07:38:23.605Z","repository":{"id":45636431,"uuid":"134604011","full_name":"andrewdyer/slim3-mailer","owner":"andrewdyer","description":"Email support for the Slim Framework using Twig and Swift Mailer.","archived":false,"fork":false,"pushed_at":"2024-12-21T17:44:14.000Z","size":98,"stargazers_count":10,"open_issues_count":1,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-12T21:43:48.977Z","etag":null,"topics":["email","emails","mailer","php","slim","slim-framework","slim-mail","slim-mailer","slim3","swiftmailer"],"latest_commit_sha":null,"homepage":"","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/andrewdyer.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2018-05-23T17:28:27.000Z","updated_at":"2024-12-21T17:44:03.000Z","dependencies_parsed_at":"2024-06-21T07:09:58.764Z","dependency_job_id":"ef70b2a2-9e3e-417e-90e9-70aa6b71bc50","html_url":"https://github.com/andrewdyer/slim3-mailer","commit_stats":{"total_commits":76,"total_committers":9,"mean_commits":8.444444444444445,"dds":"0.48684210526315785","last_synced_commit":"1cbaf0f8f321ca93764882bb56fc78fcf3febae8"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/andrewdyer/slim3-mailer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewdyer%2Fslim3-mailer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewdyer%2Fslim3-mailer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewdyer%2Fslim3-mailer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewdyer%2Fslim3-mailer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrewdyer","download_url":"https://codeload.github.com/andrewdyer/slim3-mailer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewdyer%2Fslim3-mailer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270746423,"owners_count":24638341,"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","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["email","emails","mailer","php","slim","slim-framework","slim-mail","slim-mailer","slim3","swiftmailer"],"created_at":"2024-12-17T01:16:28.084Z","updated_at":"2025-10-10T07:38:18.570Z","avatar_url":"https://github.com/andrewdyer.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eSlim3 Mailer\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://packagist.org/packages/andrewdyer/slim3-mailer\"\u003e\u003cimg src=\"https://poser.pugx.org/andrewdyer/slim3-mailer/downloads?style=for-the-badge\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/andrewdyer/slim3-mailer\"\u003e\u003cimg src=\"https://poser.pugx.org/andrewdyer/slim3-mailer/v?style=for-the-badge\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/andrewdyer/slim3-mailer\"\u003e\u003cimg src=\"https://poser.pugx.org/andrewdyer/slim3-mailer/license?style=for-the-badge\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nEmail support for the Slim Framework using Twig and \n[Swift Mailer](https://github.com/swiftmailer/swiftmailer). Mailable classes will\nmassively  tidy up your controller methods or routes, and will make sending email \na breeze.\n\n## License\n\nLicensed under MIT. Totally free for private or commercial projects.\n\n## Installation\n\n```bash\ncomposer require andrewdyer/slim3-mailer\n```\n\n## Usage\n\nAttach a new instance of `Anddye\\Mailer\\Mailer` to your applications container so \nit can be accessed anywhere you need. `Mailer` takes two arguements; an instance of \n`Slim\\Views\\Twig` and an optional array of SMTP settings.\n\n```php\n$app = new Slim\\App;\n    \n$container = $app-\u003egetContainer();\n       \n$container['mailer'] = function($container) {\n    $twig = $container['view'];\n    $mailer = new Anddye\\Mailer\\Mailer($twig, [\n        'host'      =\u003e '',  // SMTP Host\n        'port'      =\u003e '',  // SMTP Port\n        'username'  =\u003e '',  // SMTP Username\n        'password'  =\u003e '',  // SMTP Password\n        'protocol'  =\u003e ''   // SSL or TLS\n    ]);\n        \n    // Set the details of the default sender\n    $mailer-\u003esetDefaultFrom('no-reply@mail.com', 'Webmaster');\n    \n    return $mailer;\n};\n    \n$app-\u003erun();\n```\n\nIf your application doesn't use Twig views already, you will need to also attach \nthis to your container.\n\n```php\n$container['view'] = function ($container) {\n    $view = new Slim\\Views\\Twig(__DIR__ . '/../resources/views');\n    $basePath = rtrim(str_ireplace('index.php', '', $container['request']-\u003egetUri()-\u003egetBasePath()), '/');\n    $view-\u003eaddExtension(new Slim\\Views\\TwigExtension($container['router'], $basePath));\n    \n    return $view;\n};\n``` \n\n### Supported Options\n\n| Option | Type | Description |\n| --- | --- | --- |\n| host | string | The host to connect to. |\n| port | integer | The port to connect to. |\n| username | string | The username to authenticate with. |\n| password | string | The password to authenticate with. |\n| protocol | string | The encryption method, either SSL or TLS. |\n\n### Sending the Email (Basic Example)\n\n```php\n$app-\u003eget('/', function ($request, $response) use($container) {\n    $user = new stdClass;\n    $user-\u003ename = 'John Doe';\n    $user-\u003eemail = 'johndoe@mail.com';\n    \n    $container['mailer']-\u003esendMessage('emails/welcome.html.twig', ['user' =\u003e $user], function($message) use($user) {\n        $message-\u003esetTo($user-\u003eemail, $user-\u003ename);\n        $message-\u003esetSubject('Welcome to the Team!');\n    });\n    \n    $response-\u003egetBody()-\u003ewrite('Mail sent!');\n    \n    return $response;\n});\n```\n**welcome.html.twig**\n\n```html\n\u003ch1\u003eHello {{ user.name }}\u003c/h1\u003e\n    \n\u003cp\u003eWelcome to the Team!\u003c/p\u003e\n    \n\u003cp\u003eLove, Admin\u003c/p\u003e\n```\n\n### Sending with a Mailable\n\nUsing mailable classes are a lot more elegant than the basic usage example above. Building \nup the mail in a mailable class cleans up controllers and routes, making things look \na more tidy and less cluttered as well as making things so much more manageable.\n\nMailable classes are required to extend the base `Anddye\\Mailer\\Mailable` class;\n\n```php\nuse Anddye\\Mailer\\Mailable;\n\nclass WelcomeMailable extends Mailable\n{\n    \n    protected $user;\n    \n    public function __construct($user)\n    {\n        $this-\u003euser = $user;\n    }\n    \n    public function build()\n    {\n        $this-\u003esetSubject('Welcome to the Team!');\n        $this-\u003esetView('emails/welcome.html.twig', [\n            'user' =\u003e $this-\u003euser\n        ]);\n        \n        return $this;\n    }\n    \n}\n```\n\nNow in your controller or route, you set the recipients address and name, passing \njust a single argument into the `sendMessage` method - a new instance of the mailable \nclass;\n\n```php\n$app-\u003eget('/', function ($request, $response) use($container) {\n    $user = new stdClass;\n    $user-\u003ename = 'John Doe';\n    $user-\u003eemail = 'johndoe@mail.com';\n    \n    $container['mailer']-\u003esetTo($user-\u003eemail, $user-\u003ename)-\u003esendMessage(new WelcomeMailable($user));\n     \n    $response-\u003egetBody()-\u003ewrite('Mail sent!');\n    \n    return $response;\n});\n```\n\n### Methods\n\n| Method | Description |\n| --- | --- |\n| attachFile(string $path) | Path to a file to set as an attachment. |\n| detachFile(string $path) | Path to a file to remove as an attachment. |\n| setBcc(string $address, string $name = '') | Set the Bcc of the message. |\n| setBody($body) | Set the body of the message. |\n| setCc(string $address, string $name = '') | Set the Cc of the message |\n| setDate(DateTimeInterface $dateTime) | Set the date at which this message was created. |\n| setFrom(string $address, string $name = '') | Set the sender of the message. |\n| setReplyTo(string $address, string $name = '') | Set the ReplyTo of the message. |\n| setPriority(int $priority) | Set the priority of the message. |\n| setSubject(string $subject) | Set the subject of the message. |\n| setTo(string $address, string $name = '') | Set the recipent of the message. |\n\n## Support\n\nIf you are having general issues with this library, then please feel free to contact me on [Twitter](https://twitter.com/andyer92).\n\nIf you believe you have found an issue, please report it using the [issue tracker](https://github.com/andrewdyer/slim3-mailer/issues), or better yet, fork the repository and submit a pull request.\n\nIf you're using this package, I'd love to hear your thoughts!\n\n## Useful Links\n\n* [Slim Framework](https://www.slimframework.com)\n* [Slim Framework Twig View](https://github.com/slimphp/Twig-View)\n* [Swift Mailer](https://github.com/swiftmailer/swiftmailer)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewdyer%2Fslim3-mailer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrewdyer%2Fslim3-mailer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewdyer%2Fslim3-mailer/lists"}