PHP code example of andrelohmann-silverstripe / smtpmailer
1. Go to this page and download the library: Download andrelohmann-silverstripe/smtpmailer 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/ */
andrelohmann-silverstripe / smtpmailer example snippets
// smtpmailer
define('SMTPMAILER', json_encode([
"charset_encoding" => "utf-8", // E-mails characters encoding, e.g. : 'utf-8' or 'iso-8859-1'
"debug_level" => "0", // Print debugging informations. 0 = no debuging, 1 = print errors, 2 = print errors and messages, 4 = print full activity
"debug_stop" => true, // Stop Script on debugging. true = echo and die, false = echo can be catched by ob_start(); $var = ob_get_clean();
"credentials" => [
"default" => [
"server_address" => "smtp.gmail.com", // SMTP server address
"server_port" => "465", // SMTP server port. Set to 25 if no encryption or tls. Set to 465 if ssl
"secure_connection" => "ssl", // SMTP encryption method : Set to '' or 'tls' or 'ssl'
"do_authenticate" => true, // Turn on SMTP server authentication. Set to false for an anonymous connection
"username" => "__EMAILADDRESS__", // SMTP server username, if do_authenticate == true
"password" => "__PASSWORD__", // SMTP server password, if do_authenticate == true
"from" => "__EMAILADDRESS__" // From Address: e.g. "My Name" <[email protected]>, optional, use when from address needs to be fixed
],
"log" => false // false or array with credentials
]
]));
// Error Log Email Address
define('LOG_EMAIL','__EMAIL__'); // logs will be send to this address, if defined
Config::inst()->update('SmtpMailer', 'credentials', '__CREDENTIALS_SET__'); // "default" by default