PHPackages                             initphp/mailer - 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. initphp/mailer

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

initphp/mailer
==============

InitPHP Mailer Library

1.1(2y ago)168MITPHPPHP &gt;=7.4

Since Mar 15Pushed 2y ago1 watchersCompare

[ Source](https://github.com/InitPHP/Mailer)[ Packagist](https://packagist.org/packages/initphp/mailer)[ RSS](/packages/initphp-mailer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

Mailer
======

[](#mailer)

This is a simple library for sending mail with SMTP consisting of a single class.

[![Latest Stable Version](https://camo.githubusercontent.com/a031c47631a0ebe7aff9992e77c7b7e7e40a9a2df53b3de552c59cbf4a6d1355/687474703a2f2f706f7365722e707567782e6f72672f696e69747068702f6d61696c65722f76)](https://packagist.org/packages/initphp/mailer) [![Total Downloads](https://camo.githubusercontent.com/781531fac34172f6a27557af931ffa680c0f622f5836badce60acfded859d8fb/687474703a2f2f706f7365722e707567782e6f72672f696e69747068702f6d61696c65722f646f776e6c6f616473)](https://packagist.org/packages/initphp/mailer) [![Latest Unstable Version](https://camo.githubusercontent.com/bdf85539ce4e98bf42bad2076ea5b20bd7393b5ccd1cf3148d30f132a935ecf4/687474703a2f2f706f7365722e707567782e6f72672f696e69747068702f6d61696c65722f762f756e737461626c65)](https://packagist.org/packages/initphp/mailer) [![License](https://camo.githubusercontent.com/61e97d72e239fad89588aa307c88c65249f2f586a6b6875ec421d39f171d1b7f/687474703a2f2f706f7365722e707567782e6f72672f696e69747068702f6d61696c65722f6c6963656e7365)](https://packagist.org/packages/initphp/mailer) [![PHP Version Require](https://camo.githubusercontent.com/9437f7b716a7efeb70d24f9c0dce4dfd5903a055a518fc79f38da6d467cac680/687474703a2f2f706f7365722e707567782e6f72672f696e69747068702f6d61696c65722f726571756972652f706870)](https://packagist.org/packages/initphp/mailer)

Instalation
-----------

[](#instalation)

```
composer require initphp/mailer

```

Requirements
------------

[](#requirements)

- PHP 7.4 or higher
- MBString Extension
- Iconv Extension
- FileInfo Extension

Usage
-----

[](#usage)

```
$config = [
    'mailType'  => 'text' // or 'html'
    'protocol'  => 'smtp' // or 'mail' or 'sendmail'
    'SMTPAuth'  => true,
    'SMTPHost'  => 'smtp.gmail.com',
    'SMTPUser'  => 'your-mail@gmail.com',
    'SMTPPass'  => 'YourMailPassword',
    'SMTPPort'  => 587
];
$mailer = \InitPHP\Mailer\Mailer::newInstance($config);

$mailer->setFrom('info@muhammetsafak.com.tr', 'Muhammet Şafak');
//$mailer->setTo('example@example.com');
//$mailer->setCC('john@hotmail.com');
//$mailer->setBCC('testing@gmail.com');
$mailer->setSubject('Mail Subject');
$mailer->setMessage('Mail Body Message');
$mailer->send();
```

Methods
-------

[](#methods)

#### `newInstance()`

[](#newinstance)

Creates a new mailer object and returns it.

```
public static function newInstance(?array $config = null): \InitPHP\Mailer\Mailer
```

### `clear()`

[](#clear)

```
public function clear(bool $clearAttachments = false): self
```

### `setHeader()`

[](#setheader)

```
public function setHeader(string $header, string $value): self
```

### `setFrom()`

[](#setfrom)

```
public function setFrom(string $from, string $name = '', ?string $returnPath = null): self
```

### `setReplyTo()`

[](#setreplyto)

```
public function setReplyTo(string $replyTo, string $name = ''): self
```

### `setTo()`

[](#setto)

```
public function setTo(string|array $to): self
```

### `setCC()`

[](#setcc)

```
public function setCC(string $cc): self
```

### `setBCC()`

[](#setbcc)

```
public function setBCC(string $bcc, ?int $limit = null): self
```

### `setSubject()`

[](#setsubject)

```
public function setSubject(string $subject): self
```

### `setMessage()`

[](#setmessage)

```
public function setMessage(string $body): self
```

### `setAttachmentCID()`

[](#setattachmentcid)

```
public function setAttachmentCID(string $fileName): false|string
```

### `setAltMessage()`

[](#setaltmessage)

```
public function setAltMessage(string $str): self
```

### `setMailType()`

[](#setmailtype)

```
public function setMailType(string $type = 'text'): self
```

- `$type` : `text` or `html`

### `setWordWrap()`

[](#setwordwrap)

```
public function setWordWrap(bool $wordWrap = true): self
```

### `setProtocol()`

[](#setprotocol)

```
public function setProtocol(string $protocol = 'mail'): self
```

- `$protocol` : `mail`, `sendmail` or `smtp`

### `setPriority()`

[](#setpriority)

```
public function setPriority(int $n = 3): self
```

- `$n` : An integer between 1 and 5 inclusive.

### `setNewline()`

[](#setnewline)

```
public function setNewline(string $newLine = \PHP_EOL): self
```

### `setCRLF()`

[](#setcrlf)

```
public function setCRLF(string $CRLF = \PHP_EOL): self
```

### `attach()`

[](#attach)

```
public function attach(string|resource $file, string $disposition = '', ?string $newName = null, ?string $mime = null): false|self
```

### `send()`

[](#send)

```
public function send(bool $autoClear = true): bool
```

### `printDebugger()`

[](#printdebugger)

```
public function printDebugger(array $include = ['headers', 'subject', 'body']): string
```

Getting Help
------------

[](#getting-help)

If you have questions, concerns, bug reports, etc, please file an issue in this repository's Issue Tracker.

Getting Involved
----------------

[](#getting-involved)

> All contributions to this project will be published under the MIT License. By submitting a pull request or filing a bug, issue, or feature request, you are agreeing to comply with this waiver of copyright interest.

There are two primary ways to help:

- Using the issue tracker, and
- Changing the code-base.

### Using the issue tracker

[](#using-the-issue-tracker)

Use the issue tracker to suggest feature requests, report bugs, and ask questions. This is also a great way to connect with the developers of the project as well as others who are interested in this solution.

Use the issue tracker to find ways to contribute. Find a bug or a feature, mention in the issue that you will take on that effort, then follow the Changing the code-base guidance below.

### Changing the code-base

[](#changing-the-code-base)

Generally speaking, you should fork this repository, make changes in your own fork, and then submit a pull request. All new code should have associated unit tests that validate implemented features and the presence or lack of defects. Additionally, the code should follow any stylistic and architectural guidelines prescribed by the project. In the absence of such guidelines, mimic the styles and patterns in the existing code-base.

Credits
-------

[](#credits)

- [Muhammet ŞAFAK](https://www.muhammetsafak.com.tr) &lt;&gt;

License
-------

[](#license)

Copyright © 2022 [MIT License](./LICENSE)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

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

Total

2

Last Release

1031d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b6b34f3ac8938d8ee52ba3bd260680855dc5715c7b2929d9380de30d15a67dd?d=identicon)[muhammetsafak](/maintainers/muhammetsafak)

---

Top Contributors

[![muhammetsafak](https://avatars.githubusercontent.com/u/104234499?v=4)](https://github.com/muhammetsafak "muhammetsafak (2 commits)")

---

Tags

mailerphp-mailphp-mailerphp-mailer-smtp

### Embed Badge

![Health badge](/badges/initphp-mailer/health.svg)

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

###  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)
