{"id":20410262,"url":"https://github.com/oliver-schoendorn/mailer","last_synced_at":"2025-07-16T18:04:56.282Z","repository":{"id":57030973,"uuid":"99003875","full_name":"oliver-schoendorn/mailer","owner":"oliver-schoendorn","description":"A little zend-mail wrapper for easy composition of mime mails.","archived":false,"fork":false,"pushed_at":"2018-04-22T10:58:14.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-08T20:50:49.336Z","etag":null,"topics":["composer-library","mailer","mime-mails","zend-framework","zend-mail"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oliver-schoendorn.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}},"created_at":"2017-08-01T13:23:31.000Z","updated_at":"2018-04-22T10:57:45.000Z","dependencies_parsed_at":"2022-08-23T17:40:59.889Z","dependency_job_id":null,"html_url":"https://github.com/oliver-schoendorn/mailer","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/oliver-schoendorn/mailer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliver-schoendorn%2Fmailer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliver-schoendorn%2Fmailer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliver-schoendorn%2Fmailer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliver-schoendorn%2Fmailer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oliver-schoendorn","download_url":"https://codeload.github.com/oliver-schoendorn/mailer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliver-schoendorn%2Fmailer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265528826,"owners_count":23782764,"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":["composer-library","mailer","mime-mails","zend-framework","zend-mail"],"created_at":"2024-11-15T05:45:16.073Z","updated_at":"2025-07-16T18:04:56.257Z","avatar_url":"https://github.com/oliver-schoendorn.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# oliver-schoendorn/mailer\n\nThis is a little zendframework/zend-mail wrapper that will automagically construct proper multipart mime mails.\n\nPlease feel free to submit pull requests. \n\n## Installation\n```bash\ncomposer require oliver-schoendorn/mailer\n```\n\n## Usage example\n\n\n### Create new Mail object and initialize mail meta data\n```php\n\u003c?php\n\nuse OS\\Mail\\Mail;\n\n$mail = (new Mail())\n    -\u003esetSubject('email subject')\n    -\u003esetSender('foo@bar.dev', 'Foo Bar')\n    -\u003esetFrom('foo@bar.dev', 'Foo Bar')\n    -\u003esetTo('receipt@bar.dev', 'Receipt name');\n```\n\n### Add inline attachments\n\nThis is optional, but if you are using inline attachments, you have to keep track of the MailAttachment object, in order\nto reference it in the html mail body.\n\nIf an inline attachment is not being referenced, some mail clients will show the attachment or a preview below the mail,\nwhich might break your carefully crafted mail layout. \n\n```php\n\u003c?php\n\nuse OS\\Mail\\MailAttachment;\n\n$inlineImage = (new MailAttachment('file.jpg'))\n   -\u003esetContent(fopen('path/to/file.jpg', 'r'))\n   -\u003esetMimeType('image/jpg');\n\n$mail-\u003eaddInlineAttachment($inlineImage);\n```\n\n### Add body parts\n```php\n\u003c?php\n\nuse Zend\\Mime\\Mime;\nuse OS\\Mail\\MailBody;\n\n$mail-\u003eaddBodyPart((new MailBody())\n    -\u003esetMimeType(Mime::TYPE_TEXT)\n    -\u003esetContent('Plain text mail content'));\n\n$mail-\u003eaddBodyPart((new MailBody())\n    -\u003esetMimeType(Mime::TYPE_HTML)\n    -\u003esetContent('\u003chtml\u003e\u003cbody\u003e\u003cp\u003eHtml mail content\u003cimg src=\"' . $inlineImage . '\" /\u003e\u003c/p\u003e\u003c/body\u003e\u003c/html\u003e'));\n```\n\n### Add (non-inline) attachments\n\nUsually, these only appear attachment in a context menu or similar, based on the mail client used. \n\n```php\n\u003c?php\nuse OS\\Mail\\MailAttachment;\n\n$mail-\u003eaddAttachment((new MailAttachment('file.jpg'))\n    -\u003esetContent(fopen('path/to/file.jpg', 'r'))\n    -\u003esetMimeType('image/jpg'));\n```\n\n### Sending the mail\n\nTo send an mail, you can either define the transport object directly using the Zend classes or you can use the built\nin MailTransportFactory, which provides some type hinting. \n\n```php\n\u003c?php\nuse OS\\Mail\\MailTransportFactory;\n\n$mailTransport = (new MailTransportFactory())-\u003ecreateSmtpTransportWithLogin(\n    $config['mail']['user'],\n    $config['mail']['pass'],\n    $config['mail']['encryption'],\n    $config['mail']['name'],\n    $config['mail']['host'],\n    $config['mail']['port']\n);\n\n$mail-\u003esend($mailTransport);\n```\n\n## License\n\nCopyright 2018 Oliver Schöndorn\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foliver-schoendorn%2Fmailer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foliver-schoendorn%2Fmailer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foliver-schoendorn%2Fmailer/lists"}