Coder Social home page Coder Social logo

php-socket-mailer's Introduction

PHP Socket Mailer

PHP SMTP Mailer library implemented by socket

Latest Stable Version Latest Unstable Version License


DEMONSTRATION

$mailer = new \yidas\socketMailer\Mailer([
    'host' => 'mail.your.com',
    'username' => '[email protected]',
    'password' => 'passwd',
    ]);

$result = $mailer
    ->setSubject('Mail Title')
    ->setBody('Content Text')
    ->setTo(['[email protected]', '[email protected]' => 'Peter'])
    ->setFrom(['[email protected]' => 'Service Mailer'])
    ->setCc(['[email protected]' => 'CC Receiver'])
    ->setBcc(['[email protected]'])
    ->send();

REQUIREMENTS

This library requires the following:

  • PHP 5.4.0+

INSTALLATION

Run Composer in your project:

composer require yidas/socket-mailer

Then you could call it after Composer is loaded depended on your PHP framework:

require __DIR__ . '/vendor/autoload.php';

use \yidas\socketMailer\Mailer;

CONFIGURATION

To use localhost MTA:

$mailer = new \yidas\socketMailer\Mailer()

To configure a external MTA server:

$mailer = new \yidas\socketMailer\Mailer([
    'host' => 'mail.your.com',
    'username' => '[email protected]',
    'password' => 'passwd',
    'port' => 587,
    'encryption' => 'tls',
    ]);

SSL Connection

$mailer = new \yidas\socketMailer\Mailer([
    // ...
    'port' => 465,
    'encryption' => 'ssl',
    ]);

Non-Auth Connection

If you want to connect to SMTP relay server with free auth in allowed networks:

$mailer = new \yidas\socketMailer\Mailer([
    'host' => 'mail.your.com',
    'port' => 25,
    ]);

USAGES

debugOn()

public self debugOn()

setFrom()

public self setFrom(string|array $form) 

setTo()

public self setTo(array $recipients) 

setCc()

public self setCc(array $recipients) 

setBcc()

public self setBcc(array $recipients) 

setBody()

public self setBody(string $text) 

setSubject()

public self setSubject(string $title) 

addHeader()

public self addHeader($key, $value) 

Example:

$mailer = $mailer->addHeader('Your-Header-Name', 'the header value');

send()

public boolean send()

php-socket-mailer's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

973432436 2bprog

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.