2017 © Pedro Peláez
 

library external-mailer

PHP email creation and transport class for sending emails via an external address by PHPMailer

image

uralmas/external-mailer

PHP email creation and transport class for sending emails via an external address by PHPMailer

  • Sunday, March 25, 2018
  • by uralmas
  • Repository
  • 0 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

ExternalMailer - Обёртка для PHPMailer, позволяющая отправлять письма через внешний сервер

Это может полезно в следующих случаях: - На хостинге по причине безопасности отключена отправка писем через стандартные возможности - Сайт, с которого необходимо отправлять письма, заражён вирусами, которые занимаются рассылкой спама, и хостер отключил возможность отправки писем - У разных сайтов есть единый шлюз рассылки писем, (*1)

Installation & loading

PHPMailer is available on Packagist, and installation via Composer is the recommended way to install ExternalMailer. Just add this line to your composer.json file:, (*2)

"uralmas/external-mailer": "~0.2.0"

or run, (*3)

composer require uralmas/external-mailer

Использование

Библиотека состоит из 2-х частей - клиента и сервера. Клиент размещается на сайт, с которого необходимо отправить письма. Сервер - на том сайте / IP, который служит шлюзом отправки., (*4)

Client

У конструктора клиента 2 аргумента: - Первый - это адрес, по которому находится скрипт, инициализирующий серверную часть - Второй - адрес пути на сайте, на котором размещён клиент, с которого начинается адрес до прикладываемых локальных файлов (необязательный) Т.е. надо в функции addAttachment() в пути к файлу указывать адрес файла, доступный из интернета (если указан root адреса файлов, то его можно опустить), (*5)

Debugoutput указывать не надо - он будет заменён на внутренний. Для вывода сообщений дебага использовать Client->getMessages()., (*6)

<?php

require_once('./vendor/autoload.php');

try {
    //First argument - the address on which the script is located sending mail
    //Sencond - root of filepath
    $sender = new UralMas\ExternalMailer\Client('http://server.ru/', 'http://client.ru/');

    $mail = $sender->createMailer();

    //Server settings                                       // Enable verbose debug output
    $mail->isSMTP();                                        // Set mailer to use SMTP
    $mail->Host = 'smtp.mail.ru';                           // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                                 // Enable SMTP authentication
    $mail->Username = 'user@mail.ru';                       // SMTP username
    $mail->Password = 'password';                           // SMTP password
    $mail->SMTPSecure = 'ssl';                              // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 465;                                      // TCP port to connect to

    /* Other parameters and functions to configuration instanse of PHPMailer */

    //Send mails to Server part
    $send = $sender->send();

    //Debug messages
    foreach ($sender->getMessages() as $message) {
        echo $message;
    }

    $result = $sender->getResult();
} catch (\Exception $e) {
    echo $e->getMessage();
}

Server

<?php

require_once('./vendor/autoload.php');

try {
    if (! isset($_POST['mailer'])) {
        throw new Exception('Not data are send');
    }

    $mailerData = (string) $_POST['mailer'];

    $mailer = new \UralMas\ExternalMailer\Server($mailerData);

    echo $mailer->getResultSendMail();
} catch (Exception $e) {
    echo $e->getMessage();
}

License

This software is distributed under the LGPL 2.1 license. Please read LICENSE for information on the software availability and distribution., (*7)

The Versions

25/03 2018

dev-master

9999999-dev

PHP email creation and transport class for sending emails via an external address by PHPMailer

  Sources   Download

LGPL-2.1

The Requires

 

by Ivan Chudakov

25/03 2018

dev-dev

dev-dev

PHP email creation and transport class for sending emails via an external address by PHPMailer

  Sources   Download

LGPL-2.1

The Requires

 

by Ivan Chudakov

25/03 2018

0.2.0

0.2.0.0

PHP email creation and transport class for sending emails via an external address by PHPMailer

  Sources   Download

LGPL-2.1

The Requires

 

by Ivan Chudakov