# Emailer Simple send plain text and HTML e-mails over SMTP server with save messages in IMAP server. ## Installation ### Via Composer Install the package using Composer: ```bash composer require tpsoft/emailer ``` ### Via Git Repository Clone the repository directly from the Git server: ```bash git clone https://gitea.tpsoft.org/TPsoft.org/Emailer.git cd Emailer composer install ``` ## Requirements - PHP 7.0 or higher - PEAR Mail package (automatically installed via Composer) - PEAR Net_SMTP package (automatically installed via Composer) - PEAR Mail_Mime package (automatically installed via Composer) ## Usage ### Basic Example ```php array( 'host' => 'smtp.gmail.com', 'port' => 465, 'username' => 'your-email@gmail.com', 'password' => 'your-password', 'encryption' => 'ssl' ), 'imap' => array( 'host' => 'imap.gmail.com', 'port' => 993, 'encryption' => 'ssl', 'folder' => 'Sent', 'username' => 'your-email@gmail.com', 'password' => 'your-password' ) ); // Create Emailer instance $emailer = new Emailer($config); // Send email with both plain text and HTML content $emailer->send( 'recipient@example.com', 'Test Email at ' . date('Y-m-d H:i:s'), 'This is the plain text version of the message', 'This is the HTML version of the message' ); ``` ### Configuration Options #### SMTP Configuration - `host` - SMTP server hostname - `port` - SMTP server port (usually 587 for TLS, 465 for SSL) - `username` - SMTP authentication username - `password` - SMTP authentication password - `encryption` - Encryption type ('tls' or 'ssl') #### IMAP Configuration (Optional) The IMAP configuration is used to save sent messages to your mail server's sent folder: - `host` - IMAP server hostname - `port` - IMAP server port (usually 993 for SSL, 143 for non-encrypted) - `encryption` - Encryption type ('ssl' or leave empty for non-encrypted) - `folder` - Folder name where sent messages will be saved (e.g., 'Sent', 'INBOX.Sent') - `username` - IMAP authentication username - `password` - IMAP authentication password ### Method Parameters The `send()` method accepts the following parameters: ```php $emailer->send($to, $subject, $plainText, $htmlContent); ``` - `$to` - Recipient email address - `$subject` - Email subject line - `$plainText` - Plain text version of the message - `$htmlContent` - HTML version of the message (optional) ## Features - Send emails via SMTP with authentication - Support for both plain text and HTML content - Automatic saving of sent messages to IMAP folder - SSL/TLS encryption support - Easy configuration through array ## License This project is licensed under the GPL-3.0-or-later License. ## Author - **Igor Mino** - [mino@tpsoft.org](mailto:mino@tpsoft.org) ## Support For issues and questions, please visit the repository at: https://gitea.tpsoft.org/TPsoft.org/Emailer