PHP code example of rafansilva / emailsender

1. Go to this page and download the library: Download rafansilva/emailsender library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rafansilva / emailsender example snippets




/**
 * 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", "[email protected]"); //SMTP username
define("CONF_MAIL_PASS", "password"); //SMTP password
define("CONF_MAIL_SENDER", ["name" => "yourName", "address" => "[email protected]"]); //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



afaNSilva\Support\Email;

$mail = new Email();

$mail->bootstrap(
    "Example of sending email",
    "<h1>This is the HTML message body</h1>",
    "[email protected]",
    "Joe User"
)->send();

$mail->bootstrap(
    "Email with Attachments",
    "<p>See the attachment below</p>",
    "[email protected]",
    "Joe User"
)->attach(__DIR__ . "/image/joinha.jpg", "Joinha")->send();