PHPackages                             sun/sunmailer - 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. sun/sunmailer

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

sun/sunmailer
=============

SunMailer helps you to send email easily.

v1.4(10y ago)3453MITPHPPHP &gt;=5.4.0

Since Jul 13Pushed 10y ago2 watchersCompare

[ Source](https://github.com/IftekherSunny/SunMailer)[ Packagist](https://packagist.org/packages/sun/sunmailer)[ RSS](/packages/sun-sunmailer/feed)WikiDiscussions master Synced today

READMEChangelog (5)Dependencies (2)Versions (6)Used By (0)

SunMailer
---------

[](#sunmailer)

[![Build Status](https://camo.githubusercontent.com/4aa2f1d15abd43b4ddb1dcb69bebb8d50626d7de9fd76fb5111c06ced7a664f4/68747470733a2f2f7472617669732d63692e6f72672f496674656b68657253756e6e792f53756e4d61696c65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/IftekherSunny/SunMailer)[![Latest Stable Version](https://camo.githubusercontent.com/99332e7da8964057b0c10e9e31b828287fa79935112bdd692fb1a425771550a7/68747470733a2f2f706f7365722e707567782e6f72672f73756e2f73756e6d61696c65722f762f737461626c65)](https://packagist.org/packages/sun/sunmailer) [![Total Downloads](https://camo.githubusercontent.com/89238c07a58eaaf0288874d59dca987a8d585250e8b3554e18e9dd668aff0750/68747470733a2f2f706f7365722e707567782e6f72672f73756e2f73756e6d61696c65722f646f776e6c6f616473)](https://packagist.org/packages/sun/sunmailer) [![Latest Unstable Version](https://camo.githubusercontent.com/89b1a448ae19906d95953694484985e41877a909b9c01326336ac82b0608fbb8/68747470733a2f2f706f7365722e707567782e6f72672f73756e2f73756e6d61696c65722f762f756e737461626c65)](https://packagist.org/packages/sun/sunmailer) [![License](https://camo.githubusercontent.com/6e51c974d599791360f620704490e40e327089c4d801856802890e175a0b76ed/68747470733a2f2f706f7365722e707567782e6f72672f73756e2f73756e6d61696c65722f6c6963656e7365)](https://packagist.org/packages/sun/sunmailer)

SunMailer helps you to send email easily.

Installation Process
--------------------

[](#installation-process)

Just copy SunMailer folder somewhere into your project directory. Then include SunMailer autoloader.

```
  require_once('/path/to/SunMailer/autoload.php');
```

SunMailer is also available via Composer/Packagist.

```
  composer require sun/sunmailer

```

Configuration
-------------

[](#configuration)

Open config.php file located at SunMailer/config.php then,

Setup your SMTP Server ( Default set to Gmail SMTP )

```
'host'           => 'smtp.gmail.com',
'port'           =>  465,
'encryption'     => 'ssl',

```

Setup your username and password:

```
'username'      => 'example@gmail.com',
'password'      => 'secret',

```

You can also add your “from” and “reply” which will include email &amp; name.

```
'from'  => [ 'email' => 'admin@example.com', 'name' => 'Administrator' ],
'reply' => [ 'email' => 'contact@example.com', 'name' => 'Information' ],

```

Setup your email view directory. If you do not add any path of the view directory then it's pointing your root directory.

```
'view-directory'  => 'app/view'

```

If you want to test your email locally just set log to true. ( Default set to false )

```
'log'   => false

```

Send basic email
----------------

[](#send-basic-email)

```
// namespace
use SunMailer\Mailer;
use SunMailer\View;
use SunMailer\MailerException;

$email      =   'example@gmail.com';
$name       =   'Test mail name';
$subject    =   'Test mail subject';
$body       =   'Test mail body';

try
{
    if(Mailer::send($email, $name, $subject, $body))
    {
        echo 'Email has been sent successfully.';
    }
}
catch (MailerException $e)
{
    echo  'Oops!!! Something goes to wrong. '. $e->getMessage();
}
```

Email with attached file
------------------------

[](#email-with-attached-file)

```
$attached   =   'images/sunmailer.jpg';

if(Mailer::send($email, $name, $subject, $body, $attached))
{
    echo 'Email has been sent successfully.';
}

```

Send email using view render
----------------------------

[](#send-email-using-view-render)

render() method of the View class helps you to render HTML outlook.

```
View::render('to.path.test');
```

For pointing your file path use ( . ) or ( / ) , and add your file name without (.php) extension.

```
$body = View::render('email.test');

if(Mailer::send($email, $name, $subject, $body))
{
    echo 'Email has been sent successfully.';
}
```

You can also pass any value to the view template by the second parameter of the render() method (Default set to null).

```
$data  = [ 'name'  =>  'Test Name' ];
View::render('email.test', $data);
```

You need to add a placeholder ( added @ at the begining of your variable name ) for getting this data into view template. For the above an example is given below.

```
@name
```

To clean log directory
----------------------

[](#to-clean-log-directory)

```
Mailer::logClean();
```

Some of helper functions
------------------------

[](#some-of-helper-functions)

```
// to get configuration file
Helper::config();

// to get root directory path
Helper::root_path();

// to get log directory path
Helper::log_path();

// to get temp directory path
Helper::temp_path();
```

License
-------

[](#license)

This package is licensed under the [MIT License](https://github.com/iftekhersunny/SunMailer/blob/master/LICENSE)

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

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 ~14 days

Total

5

Last Release

3952d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7d233b865d7b1e1b86271e3bc70ddd077e1c01e4a83124e020fa39199c4af15a?d=identicon)[IftekherSunny](/maintainers/IftekherSunny)

---

Top Contributors

[![IftekherSunny](https://avatars.githubusercontent.com/u/8013399?v=4)](https://github.com/IftekherSunny "IftekherSunny (6 commits)")

---

Tags

phplaravelmailemailmailerphpmailerphp-mailer

### Embed Badge

![Health badge](/badges/sun-sunmailer/health.svg)

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

###  Alternatives

[railsware/mailtrap-php

The Mailtrap SDK provides methods for all API functions.

60929.1k](/packages/railsware-mailtrap-php)[hafael/azure-mailer-driver

Supercharge your Laravel or Symfony app with Microsoft Azure Communication Services (ACS)! Effortlessly add email, chat, voice, video, and telephony-over-IP for next-level communication. 🚀

15130.8k](/packages/hafael-azure-mailer-driver)[juanparati/brevosuite

Complete Brevo integration with Laravel

1014.8k](/packages/juanparati-brevosuite)[rmrevin/yii2-postman

Mail module for Yii2.

2912.3k](/packages/rmrevin-yii2-postman)

PHPackages © 2026

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