Just a powerful Service 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"
In a simple and robustly way, you could send mail messages using SMTP servers, firstly you need to create an connection, and perform authentication for the user, after that, send the message, and done.
Firstly we need a SMTP server, we'll 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("[email protected]", "pswd"));
With that, we're connected and probably authenticated (if you replaced the [email protected] and pswd with valid credentials).
Then, just send the message.
$message = new Message();
$message->from("[email protected]") // sender
->to("[email protected]") // 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.
Firstly, clone the repository.
$ git clone git://github.com/andreyknupp/SMTPClient.git
$ cd SMTPClient/
Switch 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 in the future, you can.
Thanks, you're free to contribute with anything you think can.