luiseduardobraschi / SMTPClient

Simple SMTP Client written using PHP.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SMTP Client Build Status

Just a powerful Simple Mail Transfer Protocol (SMTP) client to send mail messages.
"This is a specific guy for send mail messages over SMTP, isn't a universal mailer that covers all methods for sending a mail"

How it works.

In a simple and robustly way, you can send mail messages using SMTP servers. First of all you need to create a connection and perform authentication for the user. After that, send the message, and done.

Firstly we need an SMTP server. Here, we will use the gmail server. Using the settings from "Outgoing Mail (SMTP) Server" from Google, we'll perform the connection and authentication for the user.

<?php

require_once "config/bootstrap.php";

use utils\net\SMTP\Client; // SMTP client
use utils\net\SMTP\Client\Authentication\Login; // authentication mechanism
use utils\net\SMTP\Client\Connection\SSLConnection; // the connection
use utils\net\SMTP\Message; // the message

$client = new Client(new SSLConnection("smtp.gmail.com", 465));
$client->authenticate(new Login("user@gmail.com", "pswd"));

With that, we're connected and probably authenticated (if you replaced the user@gmail.com and pswd with valid credentials).
Then, just send the message.

$message = new Message();
$message->from("user@gmail.com") // sender
        ->to("other-user@domain.com") // receiver
        ->subject("Hello") // message subject
        ->body("Hello World"); // message content

echo $client->send($message) ? "Message sent" : "Opz";

Be happy if the message was sent.
Otherwise, you can open a issue here if you can't identify the problem type (e.g: credentials, connection [host, port]) to resolve it.

How can I use/test ?

First, clone the repository.

$ git clone git://github.com/andreyknupp/SMTPClient.git
$ cd SMTPClient/

Switch to the current directory to SMTPClient directory.

$ cd SMTPClient/

Install dependencies via composer.

$ curl -s http://getcomposer.org/installer | php
$ php composer.phar install

Performing unit tests isn't possible currently, but you will be able to in a near future.
Thanks, you're free to contribute with anything you think you can.

About

Simple SMTP Client written using PHP.


Languages

Language:PHP 100.0%