PHPackages                             gelembjuk/mail - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. gelembjuk/mail

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

gelembjuk/mail
==============

Creates email body and subject from templates using Smarty or Twig and send email with one of supported mailes (PHPMailer, mail() function etc)

1.0.1(10y ago)0921MITPHP

Since Jul 28Pushed 10mo ago3 watchersCompare

[ Source](https://github.com/Gelembjuk/mail)[ Packagist](https://packagist.org/packages/gelembjuk/mail)[ RSS](/packages/gelembjuk-mail/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (1)

Gelembjuk/Mail
--------------

[](#gelembjukmail)

PHP Package to send email with different mailers without changes in the PHP code and to format email messages using templater (Smarty, Twig).

### Installation

[](#installation)

Using composer: [gelembjuk/mail](http://packagist.org/packages/gelembjuk/mail) `require: {"gelembjuk/mail": "*"}`

### Configuration

[](#configuration)

```
$formatteroptions = array(
	'locale' => '',
		// optional, add if you need international support
	'deflocale' => 'en',
		// default locale. Optional as well, template from it are used if no in a `locale`
	'templateprocessorclass' => null,
		// if not provided then smarty is used. this is one of classes from Gelembjuk/Templating
	'templatecompiledir' => $thisdir.'/email_tmp/',
		// directory used to store tempopary files of cache engine . It i reuired for Smarty but not needed for Twig
	'templatespath' => $thisdir.'/email_templates/'
		// a base path where email templates and files with subjects are stored
	);

$maileroptions = array(
	'logger' => $logger,
		// (optional) Logger, instance of Gelembjuk\Logger\FileLogger,
	'format' => $formatteroptions,
		// formatter options
	// other options related to specified email sending class
	// next options are only for PHPMailer
	'mailsystem' => 'smtp', // for phpmailer it can be smtp or mail
	'smtp_host' => 'smtp_host', 	// aka smtp.gmail.com
	'smtp_port' => 25,		// aka 587
	'smtp_secure' => false,		// or true in case of ssl/tls
	'smtp_auth' => true,		// usually true
	'smtp_user' => 'smtp user',	// aka your gmail account
	'smtp_password' => 'smtp password', // your smtp password (gmail etc)
);
```

### Usage

[](#usage)

```
$mailer = new \Gelembjuk\Mail\PHPMailer();

// OR
// $mailer = new \Gelembjuk\Mail\PHPNative(); // uses mail()
// OR
// $mailer = new \Gelembjuk\Mail\NullMail(); // is only for testing, doesn't send only log

$mailer->initMailer($maileroptions);

$email_data = array(
	'user' => 'John Smith',
	'activationlink' => 'http://our_site.com/activateaccount/code'
);

$mailer->formatAndSendEmail(
	'activate',  // template name
	$email_data,
	'john_smith@gmail.com', // send to email
	'from_email@gmail.com'  // send from email
	);
```

#### Templates

[](#templates)

In this example a `templatespath` must contain 3 files:

activate.htm - template for this email,

```
Hello {$user}

Click the link {$activationlink}
```

out\_default.htm - common `out` template used fro all emails (aka common header/footer for all emails)

```

Header. Company name, logo etc

{$EMAILCONTENT}

Footer. Contacts, signature etc

```

subjects.xml - contains text of email subjects for templates

```

		Activate your new account
		This email is sent to a user when new account is registered

```

### Different template engines

[](#different-template-engines)

Now Smarty and Twig can be used. See  for more information. More supported engines can be added later.

### Internationalization

[](#internationalization)

See the test2.php in examples folder in this project. It shows how to organize structure of locales folders.

```
// send email with german template
$mailer->setFormatterOption('locale','de');

$mailer->formatAndSendEmail(
	'activate',  // template name
	$email_data,
	'john_smith@gmail.com', // send to email
	'from_email@gmail.com'  // send from email
	);

// send same email with french template
$mailer->setFormatterOption('locale','fr');

$mailer->formatAndSendEmail(
	'activate',  // template name
	$email_data,
	'john_smith@gmail.com', // send to email
	'from_email@gmail.com'  // send from email
	);
```

### Author

[](#author)

Roman Gelembjuk (@gelembjuk)

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~47 days

Total

2

Last Release

3899d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/af567529d048ed36455232a1f1ec9aaa9addb8eef9fb79f14acd4dbf614573a3?d=identicon)[gelembjuk](/maintainers/gelembjuk)

---

Top Contributors

[![Gelembjuk](https://avatars.githubusercontent.com/u/1552191?v=4)](https://github.com/Gelembjuk "Gelembjuk (13 commits)")

### Embed Badge

![Health badge](/badges/gelembjuk-mail/health.svg)

```
[![Health](https://phpackages.com/badges/gelembjuk-mail/health.svg)](https://phpackages.com/packages/gelembjuk-mail)
```

###  Alternatives

[tijsverkoyen/css-to-inline-styles

CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.

5.8k505.3M227](/packages/tijsverkoyen-css-to-inline-styles)[minishlink/web-push

Web Push library for PHP

1.9k12.0M53](/packages/minishlink-web-push)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[spatie/url-signer

Generate a url with an expiration date and signature to prevent unauthorized access

4422.3M16](/packages/spatie-url-signer)[mattketmo/email-checker

Throwaway email detection library

2742.0M5](/packages/mattketmo-email-checker)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
