rafansilva/emailsender

Uma biblioteca simples para enviar e-mails que abstrai o comportamento da PHPMAILER

1.0.1 2021-04-06 02:11 UTC

This package is not auto-updated.

Last update: 2024-04-16 16:51:58 UTC


README

Maintainer Source Code PHP from Packagist Latest Version Software License Build Quality Score Total Downloads

EmailSender is a class that abstracts the behavior of the PhpMailer component, and simplifies the sending of emails via SMTP.

EmailSender é uma classe que abstrai o comportamento do componente PHPMailer, e simplifica o envio de e-mails via SMTP.

Highlights

  • Simple installation (Instalação simples)
  • Simplified initial setup (Configuração inicial simplificada)
  • Simple methods for sending emails and attachments (Métodos simples para envio de e-mails e anexos)
  • Composer ready and PSR-2 compliant (Pronto para o composer e compatível com PSR-2)

Installation

Uploader is available via Composer:

"rafansilva/emailsender": "^1.0"

or run

composer require rafansilva/emailsender

Documentation

For details on how to use, see a sample folder in the component directory. In it you will have an example of use for each class. It works like this:

Para mais detalhes sobre como usar, veja uma pasta de exemplo no diretório do componente. Nela terá um exemplo de uso da classe. Ele funciona assim:

Setup to send an email:

<?php

/**
 * TIP: Put these constants in your project's config file.
 */
define("CONF_MAIL_HOST", "smtp.example.com"); //Set the SMTP server to send through
define("CONF_MAIL_PORT", 587); //TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS`
define("CONF_MAIL_USER", "user@example.com"); //SMTP username
define("CONF_MAIL_PASS", "password"); //SMTP password
define("CONF_MAIL_SENDER", ["name" => "yourName", "address" => "your@email.com"]); //Change here the name and email of who will send the email
define("CONF_MAIL_OPTION_DEBUG", 0); //To enable verbose debug output use 2 or 0 to disable
define("CONF_MAIL_OPTION_LANG", "br"); //Your language
define("CONF_MAIL_OPTION_HTML", true); //Set email format to HTML
define("CONF_MAIL_OPTION_AUTH", true); //Enable SMTP authentication
define("CONF_MAIL_OPTION_SECURE", "tls"); //Enable TLS encryption
define("CONF_MAIL_OPTION_CHARSET", "utf-8"); //Default charset is utf-8

Example of sending email and attachments:

<?php

require __DIR__ . '/../vendor/autoload.php';

use RafaNSilva\Support\Email;

$mail = new Email();

$mail->bootstrap(
    "Example of sending email",
    "<h1>This is the HTML message body</h1>",
    "joe@example.net",
    "Joe User"
)->send();

$mail->bootstrap(
    "Email with Attachments",
    "<p>See the attachment below</p>",
    "joe@example.net",
    "Joe User"
)->attach(__DIR__ . "/image/joinha.jpg", "Joinha")->send();

Contributing

Please see CONTRIBUTING for details.

Support

Security: If you discover any security related issues, please email rafaelnascimento0505@gmail.com instead of using the issue tracker.

Se você descobrir algum problema relacionado à segurança, envie um e-mail para rafaelnascimento0505@gmail.com em vez de usar o rastreador de problemas.

Thank you

Credits

License

The MIT License (MIT). Please see License File for more information.