phpSMTP

phpSMTP est une bibliothèque PHP ajoutant des fonctionnalitées a PHPMAILER.

Page Git

Fonctionnalitées

  • Authentification SMTP
  • Ajout du support de modèles de courriel

Puis-je l'utiliser?

Ce logiciel est distribué sous la licence GNU General Public License v3.0 . Veuillez lire LICENCE pour plus d'informations sur la disponibilité et la distribution du logiciel.

Localisation

Cette classe PHP prend en charge les langues en donnant la possibilité de personnaliser tous les champs de texte inclus.

Mettre a jour les champs

setTEXT.php
<?php
 
//Import SMTP class into the global namespace
//These must be at the top of your script, not inside a function
use LaswitchTech\SMTP\phpSMTP;
 
//Load Composer's autoloader
require 'vendor/autoload.php';
 
$phpSMTP = new phpSMTP();
 
$phpSMTP->setTEXT([
  "Sincerely" => "Sincerely",
  "TM and copyright" => "TM and copyright",
  "All Rights Reserved" => "All Rights Reserved",
  "Privacy Policy" => "Privacy Policy",
  "Support" => "Support",
  "This message was sent to you from an email address that does not accept incoming messages" => "This message was sent to you from an email address that does not accept incoming messages",
  "Any replies to this message will not be read. If you have questions, please visit" => "Any replies to this message will not be read. If you have questions, please visit",
]);

Sécurité

Veuillez divulguer toute vulnérabilité trouvée de manière responsable - signalez les problèmes de sécurité aux responsables en privé.

Prérequis

  • PHP version 5.5

Installation

composer require laswitchtech/php-smtp

Exemples

Modifier les paramètres

setVAR.php
<?php
 
//Import SMTP class into the global namespace
//These must be at the top of your script, not inside a function
use LaswitchTech\SMTP\phpSMTP;
 
//Load Composer's autoloader
require 'vendor/autoload.php';
 
$phpSMTP = new phpSMTP();
 
$phpSMTP->setVAR([
  "BRAND" => "phpSMTP",
  "LOGO" => "https://github.com/LouisOuellet/php-smtp/raw/stable/dist/img/logo.png",
  "FROM" => null,
  "TO" => null,
  "CC" => null,
  "BCC" => null,
  "REPLY-TO" => null,
  "SUBJECT" => "phpSMTP - Subject",
  "TITLE" => "phpSMTP - Title",
  "MESSAGE" => "phpSMTP - Message",
  "COPYRIGHT" => null,
  "TRADEMARK" => "https://domain.com/trademark",
  "POLICY" => "https://domain.com/policy",
  "SUPPORT" => "https://domain.com/support",
  "CONTACT" => "https://domain.com/contact",
]);

Authentification d'un utilisateur

login.php
<?php
 
//Import SMTP class into the global namespace
//These must be at the top of your script, not inside a function
use LaswitchTech\SMTP\phpSMTP;
 
//Load Composer's autoloader
require 'vendor/autoload.php';
 
$phpSMTP = new phpSMTP();
 
if($phpSMTP->login("username@domain.com","*******************","mail.domain.com","465","ssl")){
  echo "User Authenticated!\n";
}

Envoyer un courriel avec le modèle par défault

send.php
<?php
 
//Import SMTP class into the global namespace
//These must be at the top of your script, not inside a function
use LaswitchTech\SMTP\phpSMTP;
 
//Load Composer's autoloader
require 'vendor/autoload.php';
 
$phpSMTP = new phpSMTP();
 
$phpSMTP->connect([
  "username" => "username@domain.com",
  "password" => "*******************",
  "host" => "mail.domain.com",
  "port" => "465",
  "encryption" => "ssl",
]);
 
if($phpSMTP->isConnected()){
  echo "Connection Established!\n";
  //The send method accepts an array to update the VAR property
  if($phpSMTP->send([
    "TO" => "username@domain.com",
    "SUBJECT" => "Lorem",
    "TITLE" => "Lorem Ipsum",
    "MESSAGE" => "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
  ])){ echo "Message Sent!\n"; }
} else { echo "Connection Error!\n"; }

Utiliser un autre modèle

phpSMTP comprend 2 modèle. Le modèle par défault étant HTML et l'alternatif étant TEXT.

setTemplate.php
<?php
 
//Import SMTP class into the global namespace
//These must be at the top of your script, not inside a function
use LaswitchTech\SMTP\phpSMTP;
 
//Load Composer's autoloader
require 'vendor/autoload.php';
 
$phpSMTP = new phpSMTP();
 
//Provide a template file to use
$phpSMTP->setTemplate(dirname(__FILE__).'/templates/default.txt');

Créer votre propre modèle

Vous pouvez créer votre propre modèle en utilisant HTML ou TEXT. La classe utilise des balises comme celle-ci [TEXT-Sincerely] ou [VAR-LOGO] pour insérer le champ de texte ou le contenu variable approprié. Tous les champs de texte ou variables peuvent être utilisés.

Pour créer votre propre modèle, je vous suggère de regarder dans le répertoire des modèles.

Mise à jours

Tags

Discussion

Entrer votre commentaire:
I J Y F P