{"id":20180731,"url":"https://github.com/webfiori/mail","last_synced_at":"2026-02-03T06:02:42.504Z","repository":{"id":45803514,"uuid":"514647233","full_name":"WebFiori/mail","owner":"WebFiori","description":"Sockets-based library for sending HTML email messages.","archived":false,"fork":false,"pushed_at":"2025-10-07T22:17:20.000Z","size":412,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-10T12:16:11.158Z","etag":null,"topics":[],"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/WebFiori.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"custom":["https://paypal.me/IbrahimBinAlshikh","https://www.buymeacoffee.com/ibrahimdev"],"ko_fi":"ibrahimdev"}},"created_at":"2022-07-16T17:46:17.000Z","updated_at":"2025-10-07T22:13:14.000Z","dependencies_parsed_at":"2024-12-24T11:38:33.665Z","dependency_job_id":"dc763d82-375a-4228-9f1f-a9e6e2074dbf","html_url":"https://github.com/WebFiori/mail","commit_stats":{"total_commits":33,"total_committers":1,"mean_commits":33.0,"dds":0.0,"last_synced_commit":"027a231a532e53a69148b7fa0a3b014209dd9074"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/WebFiori/mail","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFiori%2Fmail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFiori%2Fmail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFiori%2Fmail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFiori%2Fmail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WebFiori","download_url":"https://codeload.github.com/WebFiori/mail/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFiori%2Fmail/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29035250,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T02:28:16.591Z","status":"ssl_error","status_checked_at":"2026-02-03T02:27:48.904Z","response_time":96,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-11-14T02:32:38.206Z","updated_at":"2026-02-03T06:02:42.459Z","avatar_url":"https://github.com/WebFiori.png","language":"PHP","funding_links":["https://paypal.me/IbrahimBinAlshikh","https://www.buymeacoffee.com/ibrahimdev","https://ko-fi.com/ibrahimdev"],"categories":[],"sub_categories":[],"readme":"# WebFiori Mailer \r\nA powerful and easy-to-use PHP library for sending HTML-based emails with SMTP support, OAuth authentication, and advanced features. \r\n\r\n\r\n\u003cp align=\"center\"\u003e\r\n  \u003ca target=\"_blank\" href=\"https://github.com/WebFiori/mail/actions/workflows/php84.yaml\"\u003e\r\n    \u003cimg src=\"https://github.com/WebFiori/mail/actions/workflows/php84.yaml/badge.svg?branch=main\"\u003e\r\n  \u003c/a\u003e\r\n  \u003ca href=\"https://codecov.io/gh/WebFiori/mail\"\u003e\r\n    \u003cimg src=\"https://codecov.io/gh/WebFiori/mail/branch/main/graph/badge.svg\" /\u003e\r\n  \u003c/a\u003e\r\n  \u003ca href=\"https://sonarcloud.io/dashboard?id=WebFiori_mail\"\u003e\r\n      \u003cimg src=\"https://sonarcloud.io/api/project_badges/measure?project=WebFiori_mail\u0026metric=alert_status\" /\u003e\r\n  \u003c/a\u003e\r\n  \u003ca href=\"https://github.com/WebFiori/mail/releases\"\u003e\r\n      \u003cimg src=\"https://img.shields.io/github/release/WebFiori/mail.svg?label=latest\" /\u003e\r\n  \u003c/a\u003e\r\n  \u003ca href=\"https://packagist.org/packages/webfiori/mailer\"\u003e\r\n    \u003cimg src=\"https://img.shields.io/packagist/dt/webfiori/mailer?color=light-green\"\u003e\r\n  \u003c/a\u003e\r\n\u003c/p\u003e\r\n\r\n## Supported PHP Versions\r\n|                                                                                        Build Status                                                                                        |\r\n|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|\r\n| \u003ca target=\"_blank\" href=\"https://github.com/WebFiori/mail/actions/workflows/php81.yaml\"\u003e\u003cimg src=\"https://github.com/WebFiori/mail/actions/workflows/php81.yaml/badge.svg?branch=main\"\u003e\u003c/a\u003e  |\r\n| \u003ca target=\"_blank\" href=\"https://github.com/WebFiori/mail/actions/workflows/php82.yaml\"\u003e\u003cimg src=\"https://github.com/WebFiori/mail/actions/workflows/php82.yaml/badge.svg?branch=main\"\u003e\u003c/a\u003e  |\r\n| \u003ca target=\"_blank\" href=\"https://github.com/WebFiori/mail/actions/workflows/php83.yaml\"\u003e\u003cimg src=\"https://github.com/WebFiori/mail/actions/workflows/php83.yaml/badge.svg?branch=main\"\u003e\u003c/a\u003e  |\r\n| \u003ca target=\"_blank\" href=\"https://github.com/WebFiori/mail/actions/workflows/php84.yaml\"\u003e\u003cimg src=\"https://github.com/WebFiori/mail/actions/workflows/php84.yaml/badge.svg?branch=main\"\u003e\u003c/a\u003e  |\r\n\r\n## In This Page:\r\n* [Installation](#installation)\r\n* [Examples](#examples)\r\n* [Usage](#usage)\r\n  * [Basic Usage](#basic-usage)\r\n    * [Connecting to SMTP Server](#connecting-to-smtp-server)\r\n    * [Creating Email Message](#creating-email-message)\r\n    * [Setting Email Subject](#setting-email-subject)\r\n    * [Adding a Recipient](#adding-a-recipient)\r\n    * [Writing Some Text](#writing-some-text)\r\n    * [Sending The Message](#sending-the-message)\r\n    * [All Together](#all-together)\r\n  * [Fluent Interface](#fluent-interface)\r\n  * [OAuth Authentication](#oauth-authentication)\r\n* [Attachments](#attachments)\r\n* [Before Send Callback](#before-send-callback)\r\n* [After Send Callback](#after-send-callback)\r\n* [Accessing SMTP Log](#accessing-smtp-log)\r\n* [Storing Email](#storing-email)\r\n* [Setup Testing](#setup-testing)\r\n\r\n## Installation\r\n\r\nInstall via Composer:\r\n\r\n```bash\r\ncomposer require webfiori/mailer\r\n```\r\n\r\n## Examples\r\n\r\nComprehensive examples are available in the [`examples/`](examples/) directory:\r\n\r\n- **[Basic Usage](examples/basic-usage/)** - Fundamental email sending and fluent interface\r\n- **[OAuth Authentication](examples/oauth-usage/)** - Gmail and Microsoft OAuth integration  \r\n- **[File Attachments](examples/attachments/)** - Adding files to emails\r\n- **[Sending Modes](examples/sending-modes/)** - Test, development, and production configurations\r\n- **[SMTP Logging](examples/accessing-log/)** - Debugging and monitoring\r\n- **[Callbacks](examples/callbacks/)** - Before/after send custom logic\r\n\r\n## Usage\r\n\r\n### Basic Usage\r\n\r\nThis section describes most basic use case of the library. It shows how to connect to SMTP server, writing a message and sending it to specific address.\r\n\r\n#### Connecting to SMTP Server\r\n\r\nConnection information are represented using an instance of the class [`WebFiori\\Mail\\SMTPAccount`](https://github.com/WebFiori/mail/blob/main/WebFiori/Mail/SMTPAccount.php).\r\n``` php\r\n\u003c?php\r\nrequire '../vendor/autoload.php';\r\n\r\nuse WebFiori\\Mail\\SMTPAccount;\r\nuse WebFiori\\Mail\\AccountOption;\r\n\r\n//First, create new SMTP account that holds SMTP connection information.\r\n$smtp = new SMTPAccount([\r\n    AccountOption::PORT =\u003e 465,\r\n\r\n    //Replace server address with your mail server address\r\n    AccountOption::SERVER_ADDRESS =\u003e 'mail.example.com',\r\n\r\n    //Replace server username with your mail server username\r\n    AccountOption::USERNAME =\u003e 'test@example.com',\r\n\r\n    AccountOption::PASSWORD =\u003e 'KnvcbxFYCz77',\r\n\r\n    AccountOption::SENDER_NAME =\u003e 'Ibrahim',\r\n\r\n    //Replace sender address with your mail server sender address\r\n    AccountOption::SENDER_ADDRESS =\u003e 'test@example.com',\r\n\r\n    AccountOption::NAME =\u003e 'no-reply'\r\n]);\r\n```\r\n\r\n#### Creating Email Message\r\n\r\nAfter having SMTP connection information, an instance of the class [`WebFiori\\Mail\\Email`](https://github.com/WebFiori/mail/blob/dev/WebFiori/Mail/Email.php) can be created. The consructor of the class will accept one parameter which is the connection that will be used to connect to SMTP server.\r\n\r\n``` php\r\n//Second, create your actual email. using the account that was just created to\r\n//send messages.\r\n$email = new Email($smtp);\r\n```\r\n#### Setting Email Subject\r\n\r\nTo set the subject of the message, the method `Email::setSubject()` can be used as follows:\r\n``` php\r\n//Set subject\r\n$email-\u003esetSubject('Hello World From PHP 😀');\r\n```\r\n\r\n#### Adding a Recipient\r\n\r\n``` php\r\n//Specify who will receive the message\r\n$email-\u003eaddTo('super-megaman-x@outlook.com');\r\n```\r\n\r\n#### Writing Some Text\r\n\r\nThe email messages which are created using the library are HTML based. They utilize the library [`webfiori\\ui`](https://github.com/WebFiori/ui) to build the virtual DOM.\r\n\r\nAn HTML elemtnt can be inserted to the body of the message by using the method `Email::insert()`.\r\n\r\n``` php\r\n\r\n//Build your HTML Message\r\n$div = $email-\u003einsert('div');\r\n$div-\u003eaddChild('p')-\u003etext('Hello World Message');\r\n$div-\u003eaddChild('p', [\r\n    'style' =\u003e [\r\n        'font-weight' =\u003e 'bold',\r\n        'color' =\u003e 'red'\r\n    ]\r\n])-\u003etext('This is just a test message.');\r\n```\r\n\r\n#### Sending The Message\r\n\r\nThe final step is to send the message. This can be performed using the method `Email::send()`.\r\n\r\n``` php\r\n//Finally, send.\r\n$email-\u003esend();\r\n```\r\n\r\n#### All Together\r\n\r\nWhen we put all the steps as one, we would have the following:\r\n\r\n``` php\r\nrequire '../vendor/autoload.php';\r\n\r\nuse WebFiori\\Mail\\AccountOption;\r\nuse WebFiori\\Mail\\SMTPAccount;\r\nuse WebFiori\\Mail\\Email;\r\n\r\n$smtp = new SMTPAccount([\r\n    AccountOption::PORT =\u003e 465,\r\n    AccountOption::SERVER_ADDRESS =\u003e 'mail.example.com',\r\n    AccountOption::USERNAME =\u003e 'test@example.com',\r\n    AccountOption::PASSWORD =\u003e 'KnvcbxFYCz77',\r\n    AccountOption::SENDER_NAME =\u003e 'Ibrahim',\r\n    AccountOption::SENDER_ADDRESS =\u003e 'test@example.com',\r\n    AccountOption::NAME =\u003e 'no-reply'\r\n]);\r\n\r\n$email = new Email($smtp);\r\n\r\n$email-\u003esetSubject('Hello World From PHP 😀');\r\n\r\n$email-\u003eaddTo('super-megaman-x@outlook.com');\r\n\r\n$div = $email-\u003einsert('div');\r\n$div-\u003eaddChild('p')-\u003etext('Hello World Message');\r\n$div-\u003eaddChild('p', [\r\n    'style' =\u003e [\r\n        'font-weight' =\u003e 'bold',\r\n        'color' =\u003e 'red'\r\n    ]\r\n])-\u003etext('This is just a test message.');\r\n\r\n$email-\u003esend();\r\n```\r\n### Fluent Interface\r\n\r\nWebFiori Mailer supports method chaining for a more readable and concise syntax:\r\n\r\n```php\r\n$email = new Email($smtpAccount);\r\n\r\n$email-\u003eto('recipient@example.com', 'Recipient Name')\r\n      -\u003ecc('manager@example.com', 'Manager')\r\n      -\u003esubject('Hello from WebFiori Mailer!')\r\n      -\u003epriority(1)\r\n      -\u003esend();\r\n```\r\n\r\nAvailable fluent methods:\r\n- `to()` - Add TO recipient\r\n- `cc()` - Add CC recipient  \r\n- `bcc()` - Add BCC recipient\r\n- `subject()` - Set email subject\r\n- `attach()` - Add attachment\r\n- `priority()` - Set email priority\r\n\r\n### OAuth Authentication\r\n\r\nWebFiori Mailer supports OAuth2 authentication for enhanced security with modern email providers:\r\n\r\n#### Gmail OAuth\r\n```php\r\n$gmailAccount = new SMTPAccount([\r\n    AccountOption::SERVER_ADDRESS =\u003e 'smtp.gmail.com',\r\n    AccountOption::PORT =\u003e 587,\r\n    AccountOption::USERNAME =\u003e 'your-email@gmail.com',\r\n    AccountOption::ACCESS_TOKEN =\u003e 'your-oauth-access-token',\r\n    AccountOption::SENDER_ADDRESS =\u003e 'your-email@gmail.com',\r\n    AccountOption::SENDER_NAME =\u003e 'Your Name',\r\n    AccountOption::NAME =\u003e 'gmail-oauth'\r\n]);\r\n```\r\n\r\n#### Microsoft OAuth\r\n```php\r\n$microsoftAccount = new SMTPAccount([\r\n    AccountOption::SERVER_ADDRESS =\u003e 'smtp-mail.outlook.com',\r\n    AccountOption::PORT =\u003e 587,\r\n    AccountOption::USERNAME =\u003e 'your-email@outlook.com',\r\n    AccountOption::ACCESS_TOKEN =\u003e 'your-microsoft-oauth-token',\r\n    AccountOption::SENDER_ADDRESS =\u003e 'your-email@outlook.com',\r\n    AccountOption::SENDER_NAME =\u003e 'Your Name',\r\n    AccountOption::NAME =\u003e 'microsoft-oauth'\r\n]);\r\n```\r\n\r\nSee the [OAuth examples](examples/oauth-usage/) for complete setup instructions.\r\n## Attachments\r\n\r\nAttachments can be added to any email using the method `Email::addAttachment()`. The method accepts a single parameter. The parameter can be a `string` which represents the absolute path of the file to be attached or an object of type `webfiori\\file\\File`.\r\n\r\n``` php\r\nuse WebFiori\\Mail\\AccountOption;\r\nuse WebFiori\\Mail\\SMTPAccount;\r\nuse WebFiori\\Mail\\Email;\r\nuse webfiori\\file\\File;\r\n\r\n$smtp = new SMTPAccount([\r\n    AccountOption::PORT =\u003e 465,\r\n    AccountOption::SERVER_ADDRESS =\u003e 'mail.example.com',\r\n    AccountOption::USERNAME =\u003e 'test@example.com',\r\n    AccountOption::PASSWORD =\u003e 'KnvcbxFYCz77',\r\n    AccountOption::SENDER_NAME =\u003e 'Ibrahim',\r\n    AccountOption::SENDER_ADDRESS =\u003e 'test@example.com',\r\n    AccountOption::NAME =\u003e 'no-reply'\r\n]);\r\n\r\n$email = new Email($smtp);\r\n \r\n$email-\u003eaddAttachment('Attach00.txt');\r\n$email-\u003eaddAttachment(new File('another.txt'));\r\n```\r\n\r\n## Before Send Callback\r\n\r\nSuppose that a developer would like to perform a task everytime the method `Email::send()` is called, and that event must be called before connecting to SMTP server. In such case, the developer can use the method `Email::addBeforeSend()`. The method accepts two parameters, first one is a `function` callback and second one is an optional array of parameters to be passed to the callback. \r\n\r\n``` php\r\n$smtp = new SMTPAccount([\r\n    AccountOption::PORT =\u003e 465,\r\n    AccountOption::SERVER_ADDRESS =\u003e 'mail.example.com',\r\n    AccountOption::USERNAME =\u003e 'test@example.com',\r\n    AccountOption::PASSWORD =\u003e 'KnvcbxFYCz77',\r\n    AccountOption::SENDER_NAME =\u003e 'Ibrahim',\r\n    AccountOption::SENDER_ADDRESS =\u003e 'test@example.com',\r\n    AccountOption::NAME =\u003e 'no-reply'\r\n]);\r\n\r\n$email = new Email($smtp);\r\n$email-\u003esetSubject('Hello World From PHP 😀');\r\n$email-\u003eaddTo('super-megaman-x@outlook.com');\r\n\r\n$email-\u003eaddBeforeSend(function (Email $e) {\r\n  $e-\u003einsert('p')-\u003etext('This text is added before sending');\r\n});\r\n\r\n$div = $email-\u003einsert('div');\r\n$div-\u003eaddChild('p')-\u003etext('Hello World Message');\r\n\r\n$email-\u003esend();\r\n\r\n```\r\n\r\n## After Send Callback\r\n\r\nSuppose that a developer would like to perform a task everytime the method `Email::send()` is called, and that event must be called after sending the email. In such case, the developer can use the method `Email::addAfterSend()`. The method accepts two parameters, first one is a `function` callback and second one is an optional array of parameters to be passed to the callback. \r\n\r\n``` php\r\n$smtp = new SMTPAccount([\r\n    AccountOption::PORT =\u003e 465,\r\n    AccountOption::SERVER_ADDRESS =\u003e 'mail.example.com',\r\n    AccountOption::USERNAME =\u003e 'test@example.com',\r\n    AccountOption::PASSWORD =\u003e 'KnvcbxFYCz77',\r\n    AccountOption::SENDER_NAME =\u003e 'Ibrahim',\r\n    AccountOption::SENDER_ADDRESS =\u003e 'test@example.com',\r\n    AccountOption::NAME =\u003e 'no-reply'\r\n]);\r\n\r\n$email = new Email($smtp);\r\n$email-\u003esetSubject('Hello World From PHP 😀');\r\n$email-\u003eaddTo('super-megaman-x@outlook.com');\r\n\r\n$email-\u003eaddAfterSend(function (Email $e) {\r\n // Do any action like storing the log.\r\n});\r\n\r\n$div = $email-\u003einsert('div');\r\n$div-\u003eaddChild('p')-\u003etext('Hello World Message');\r\n\r\n$email-\u003esend();\r\n\r\n```\r\n\r\n\r\n## Accessing SMTP Log\r\n\r\nOne of the features of the library is the logging of SMTP commands that was sent to server. This is useful in case the developer would like to trace the cause of send failure. To access the log events, the method `Email::getLog()` can be used. The method will return an array that holds sub-assiciative arrays. each associative array will have 3 indices, `command`, `response-code` and `response-message`.\r\n\r\n``` php\r\nforeach ($email-\u003egetLog() as $logEvent) {\r\n  echo ' Command: '.$logEvent['command'];\r\n  echo ' Code: '.$logEvent['response-code'];\r\n  echo ' Message: '.$logEvent['response-message'];\r\n}\r\n```\r\n\r\n## Storing Email\r\n\r\nSince the emails which are constructed using the library are HTML based, they can be stored as HTML web pages. This feature is useful in case the developer would like to test a preview of final constructed email.\r\n\r\nTo store an email as HTML web page, the method `Email::storeEmail()` can be used as follows:\r\n\r\n``` php\r\n$m = new Email(new SMTPAccount([\r\n    AccountOption::PORT =\u003e 465,\r\n    AccountOption::SERVER_ADDRESS =\u003e 'mail.example.com',\r\n    AccountOption::USERNAME =\u003e 'test@example.com',\r\n    AccountOption::PASSWORD =\u003e 'KnvcbxFYCz77',\r\n    AccountOption::SENDER_NAME =\u003e 'Ibrahim',\r\n    AccountOption::SENDER_ADDRESS =\u003e 'test@example.com',\r\n    AccountOption::NAME =\u003e 'no-reply'\r\n]));\r\n$m-\u003esetSubject('Test Ability to Store Email');\r\n$m-\u003eaddTo('ibx@example.com');\r\n$m-\u003einsert('p')-\u003etext('Dear,')-\u003esetStyle([\r\n    'font-weight' =\u003e 'bold',\r\n    'font-size' =\u003e '15pt'\r\n]);\r\n$m-\u003einsert('p')-\u003etext('This email is just to inform you that you can store emails as web pages.');\r\n$m-\u003einsert('p')-\u003etext('Regards,')-\u003esetStyle([\r\n    'color' =\u003e 'green',\r\n    'font-weight' =\u003e 'bold'\r\n]);\r\n$m-\u003estoreEmail('/path/to/email/file');\r\n```\r\n\r\nThe call to the method `Email::storeEmail()` will do the following:\r\n\r\n* Render the final email.\r\n* Create a folder which has same subject as the email inside provided folder.\r\n* Create HTML file which has the date and time as its name inside the folder.\r\n\r\nThe final output of the given code will be HTML web page that is similar to following image.\r\n\r\n![image](https://github.com/WebFiori/mail/assets/12120015/abe81167-8743-4fd1-ab7a-c16d2bbd1411)\r\n\r\n## Setup Testing\r\n\r\nWhen testing the email, we usually intersted on seeing the final look of the email in addition to knowing who are the recepints of the email. The library provides the developer with two options for testing email messages:\r\n* Storing them as HTML web pages\r\n* Sending them to specific addresses.\r\n\r\nThe two testing modes are controlled by the method `Email::setMode()`. The method is used to set the mode at which the email will use when the method `Email::send` is called.\r\n\r\n### Storing as Web Pages\r\n\r\nIn this case, the mode of sending the message should be set to `SendMode::TEST_STORE`. Additionally, the location at which the message will be stored at must be provided.\r\n\r\n``` php\r\n\r\n$m = new Email(new SMTPAccount([\r\n    AccountOption::PORT =\u003e 465,\r\n    AccountOption::SERVER_ADDRESS =\u003e 'mail.example.com',\r\n    AccountOption::USERNAME =\u003e 'test@example.com',\r\n    AccountOption::PASSWORD =\u003e 'KnvcbxFYCz77',\r\n    AccountOption::SENDER_NAME =\u003e 'Ibrahim',\r\n    AccountOption::SENDER_ADDRESS =\u003e 'test@example.com',\r\n    AccountOption::NAME =\u003e 'no-reply'\r\n]));\r\n\r\n//Here, set the mode to testing and storing.\r\n$m-\u003esetMode(SendMode::TEST_STORE, [\r\n    'store-path' =\u003e '/path/to/store/message'\r\n]);\r\n\r\n\r\n$m-\u003esetSubject('Test Ability to Store Email');\r\n$m-\u003eaddTo('ibx@example.com');\r\n$m-\u003einsert('p')-\u003etext('Dear,')-\u003esetStyle([\r\n    'font-weight' =\u003e 'bold',\r\n    'font-size' =\u003e '15pt'\r\n]);\r\n$m-\u003einsert('p')-\u003etext('This email is just to inform you that you can store emails as web pages.');\r\n$m-\u003einsert('p')-\u003etext('Regards,')-\u003esetStyle([\r\n    'color' =\u003e 'green',\r\n    'font-weight' =\u003e 'bold'\r\n]);\r\n$m-\u003esend();\r\n\r\n\r\n```\r\n\r\n### Sending to Test Addresses\r\n\r\nIn this case, the mode of sending the message should be set to `SendMode::TEST_SEND`. Additionally, the addresses of the users who will receive the email must be provided.\r\n\r\n``` php\r\n\r\n$m = new Email(new SMTPAccount([\r\n    AccountOption::PORT =\u003e 465,\r\n    AccountOption::SERVER_ADDRESS =\u003e 'mail.example.com',\r\n    AccountOption::USERNAME =\u003e 'test@example.com',\r\n    AccountOption::PASSWORD =\u003e 'KnvcbxFYCz77',\r\n    AccountOption::SENDER_NAME =\u003e 'Ibrahim',\r\n    AccountOption::SENDER_ADDRESS =\u003e 'test@example.com',\r\n    AccountOption::NAME =\u003e 'no-reply'\r\n]));\r\n\r\n//Here, set the mode to testing and storing.\r\n$m-\u003esetMode(SendMode::TEST_SEND, [\r\n    'send-addresses' =\u003e [\r\n        'addr1@example.com',\r\n        'addr2@example.com',\r\n    ]\r\n]);\r\n\r\n\r\n$m-\u003esetSubject('Test Ability to Store Email');\r\n$m-\u003eaddTo('ibx@example.com');\r\n$m-\u003einsert('p')-\u003etext('Dear,')-\u003esetStyle([\r\n    'font-weight' =\u003e 'bold',\r\n    'font-size' =\u003e '15pt'\r\n]);\r\n$m-\u003einsert('p')-\u003etext('This email is just to inform you that you can store emails as web pages.');\r\n$m-\u003einsert('p')-\u003etext('Regards,')-\u003esetStyle([\r\n    'color' =\u003e 'green',\r\n    'font-weight' =\u003e 'bold'\r\n]);\r\n$m-\u003esend();\r\n\r\n\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebfiori%2Fmail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebfiori%2Fmail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebfiori%2Fmail/lists"}