Skip to content

yidas/php-socket-mailer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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' => 'service@your.com', 'password' => 'passwd', ]); $result = $mailer ->setSubject('Mail Title') ->setBody('Content Text') ->setTo(['name@your.com', 'peter@your.com' => 'Peter']) ->setFrom(['service@your.com' => 'Service Mailer']) ->setCc(['cc@your.com' => 'CC Receiver']) ->setBcc(['bcc@your.com']) ->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' => 'service@your.com', '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()

About

PHP SMTP Mailer library implemented by socket

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages