{"id":15029018,"url":"https://github.com/eoghanobrien/php-simple-mail","last_synced_at":"2025-04-13T07:49:21.053Z","repository":{"id":617387,"uuid":"256187","full_name":"eoghanobrien/php-simple-mail","owner":"eoghanobrien","description":"Provides a simple, chainable wrapper for creating and sending emails using the PHP mail() function.","archived":false,"fork":false,"pushed_at":"2022-10-06T00:30:26.000Z","size":293,"stargazers_count":205,"open_issues_count":7,"forks_count":89,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-04-13T07:49:16.880Z","etag":null,"topics":["attachments","chainable-methods","emails","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"ha/doozerd","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eoghanobrien.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-07-20T22:32:52.000Z","updated_at":"2025-01-16T10:34:05.000Z","dependencies_parsed_at":"2022-07-07T11:14:10.649Z","dependency_job_id":null,"html_url":"https://github.com/eoghanobrien/php-simple-mail","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eoghanobrien%2Fphp-simple-mail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eoghanobrien%2Fphp-simple-mail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eoghanobrien%2Fphp-simple-mail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eoghanobrien%2Fphp-simple-mail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eoghanobrien","download_url":"https://codeload.github.com/eoghanobrien/php-simple-mail/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248681494,"owners_count":21144700,"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":["attachments","chainable-methods","emails","php"],"created_at":"2024-09-24T20:09:33.680Z","updated_at":"2025-04-13T07:49:21.032Z","avatar_url":"https://github.com/eoghanobrien.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# README\n\n[![Build Status](https://travis-ci.org/eoghanobrien/php-simple-mail.png?branch=master)](https://travis-ci.org/eoghanobrien/php-simple-mail)\n[![Latest Stable Version](https://poser.pugx.org/eoghanobrien/php-simple-mail/v/stable.png)](https://packagist.org/packages/eoghanobrien/php-simple-mail)\n[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/eoghanobrien/php-simple-mail/badges/quality-score.png?s=a6850c4ef51c0d56ed50513d3749d6c1617dfaff)](https://scrutinizer-ci.com/g/eoghanobrien/php-simple-mail/)\n[![Code Coverage](https://scrutinizer-ci.com/g/eoghanobrien/php-simple-mail/badges/coverage.png?s=d167e7faf23471deeef69d26ff23812a64e74326)](https://scrutinizer-ci.com/g/eoghanobrien/php-simple-mail/)\n[![Total Downloads](https://poser.pugx.org/eoghanobrien/php-simple-mail/downloads.png)](https://packagist.org/packages/eoghanobrien/php-simple-mail)\n[![License](https://poser.pugx.org/eoghanobrien/php-simple-mail/license.png)](https://packagist.org/packages/eoghanobrien/php-simple-mail)\n[![PHP 7 ready](http://php7ready.timesplinter.ch/eoghanobrien/php-simple-mail/master/badge.svg)](https://travis-ci.org/eoghanobrien/php-simple-mail)\n\n## Introduction\n\nSimple Mail Class provides a simple, chainable wrapper for creating and sending emails using the PHP `mail()` function. There are better options out there for sending SMTP email, which are more secure and more reliable than the `mail()` function. However, sometimes you just need to send a simple email. That's what we cover.\n\n## Installation via Composer\n\n```\n$ composer require eoghanobrien/php-simple-mail\n```\n\n## Usage\n\n### Instantiating the class.\n\nYou have two options, you can 'new up' the class in the traditional way:\n\n```php\n$mailer = new SimpleMail();\n```\nor instantiate it using the named static constructor `make()`\n```php\n$mailer = SimpleMail::make();\n```\nThe static constructor can be useful when you want to continue chaining methods after instantiating.\n```php\nSimpleMail::make()\n-\u003esetTo($email, $name)\n-\u003esetFrom($fromEmail, $fromName)\n-\u003esetSubject($subject)\n-\u003esetMessage($message)\n-\u003esend();\n```\n \n\n\n### `To` header\n \nThe `To` header can be called multiple time, in order to pass more than one `To` address, simply call the `setTo` method as many times as needed. It takes two string parameters. The first parameter is for the email address, the second is for the name.\n \n```php\nSimpleMail::make()\n -\u003esetTo($email1, $name1)\n -\u003esetTo($email2, $name2);\n```\n \n \n### `From` header\n\nYou can carbon copy one or more addresses using the `setBcc` method. It takes two string parameters. The first parameter is for the email address, the second is for the name.\n\n```php\nSimpleMail::make()\n  -\u003esetFrom('john.smith@example.com', 'John Smith');\n```\n \n \n \n### `Cc` header\n\nYou can carbon copy one or more addresses using the `setCc` method. It takes an array of `$name =\u003e $email` pairs. Alternatively, you can pass a simple numerically keyed array an the value is assumed to be the email.\n\n```php\nSimpleMail::make()\n  -\u003esetCc(['John Smith', 'john.smith@example.com');\n```\n \n \n### `Bcc` header\n\nYou can blind carbon copy one or more addresses using the `setBcc` method. It takes an array of `$name =\u003e $email` pairs. Alternatively, you can pass a simple numerically keyed array an the value is assumed to be the email.\n\n```php\nSimpleMail::make()\n  -\u003esetBcc(['John Smith', 'john.smith@example.com');\n```\n \n### `Subject` header\n\nYou can set the subject using `setSubject` method. It takes a string as the only parameter.\n\n```php\nSimpleMail::make()\n    -\u003esetSubject(\"Important information about your account\");\n```\n \n### `Message` header\n\nYou can set the message using `setMessage` method. It takes a string as the only parameter.\n\n```php\nSimpleMail::make()\n    -\u003esetMessage(\"My important message!\");\n```\n\n### `HTML` emails\n\nIf you want to include HTML in your email. Simply call the `setHtml()` method. It takes no parameters.\n\n```php\nSimpleMail::make()\n    -\u003esetMessage(\"\u003cstrong\u003eMy important message!\u003c/strong\u003e\")\n    -\u003esetHtml();\n```\n\n### `send` emails\n\nOnce you've set all your headers. Use the `send()` method to finally send it on it's way.\n\n```php\nSimpleMail::make()\n    -\u003esetMessage(\"\u003cstrong\u003eMy important message!\u003c/strong\u003e\")\n    -\u003esend();\n```\n \n### Full example of sending an email\n \n```php\n$send = SimpleMail::make()\n    -\u003esetTo($email, $name)\n    -\u003esetFrom($fromEmail, $fromName)\n    -\u003esetSubject($subject)\n    -\u003esetMessage($message)\n    -\u003esetReplyTo($replyEmail, $replyName)\n    -\u003esetCc(['Bill Gates' =\u003e 'bill@example.com'])\n    -\u003esetBcc(['Steve Jobs' =\u003e 'steve@example.com'])\n    -\u003esetHtml()\n    -\u003esetWrap(100)\n    -\u003esend();\n    \necho ($send) ? 'Email sent successfully' : 'Could not send email';\n```\n\n### Example of sending an email with attachments\n\nIf you are sending an attachment there is no need to add any addGenericHeader()'s. To properly send the attachments the necessary headers will be set for you. You can also chain as many attachments as you want (see example).\n\n```php\n$send = SimpleMail::make()\n    -\u003esetTo($email, $name)\n    -\u003esetFrom($fromEmail, $fromName)\n    -\u003esetSubject($subject)\n    -\u003esetMessage($message)\n    -\u003esetReplyTo($replyEmail, $replyName)\n    -\u003esetCc(['Bill Gates' =\u003e 'bill@example.com'])\n    -\u003esetBcc(['Steve Jobs' =\u003e 'steve@example.com'])\n    -\u003esetHtml()\n    -\u003esetWrap(100)\n    -\u003eaddAttachment('example/pbXBsZSwgY2hh.jpg', 'lolcat_finally_arrived.jpg')\n    -\u003eaddAttachment('example/lolcat_what.jpg')\n    -\u003esend();\n    \necho ($send) ? 'Email sent successfully' : 'Could not send email';\n```\n\n## License\nphp-simple-mail is free and unencumbered public domain software. For more information, see [http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT) or the accompanying MIT file.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feoghanobrien%2Fphp-simple-mail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feoghanobrien%2Fphp-simple-mail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feoghanobrien%2Fphp-simple-mail/lists"}