1. Go to this page and download the library: Download benjosiah/smtp-express-php 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/ */
benjosiah / smtp-express-php example snippets
use SmtpExpress\SmtpExpress;
r-project-secret');
use SmtpExpress\Mail\SendMail;
$email = (new SendMail())
->subject('Welcome To Express')
->message('<h1>Hello from SMTP Express</h1><p>Enjoy fast email delivery!</p>')
->sender('[email protected]', 'SMTP SERVER')
->recipients('[email protected]', 'Ben Josiah');
$response = $smtp->sendEmail($email);
use SmtpExpress\Mail\SendMail;
use SmtpExpress\Templates\Template;
use SmtpExpress\Templates\TemplateRenderer;
// Load HTML template
$template = new Template(file_get_contents('email.html'));
// Render with variables
$renderer = new TemplateRenderer();
$html = $renderer->render($template, [
'name' => 'Josiah',
'company' => 'SMTPExpress Inc.',
'url' => 'https://yourapp.com/reset-password'
]);
// Build email
$email = (new SendMail())
->subject('Welcome To Express')
->message($html)
->sender('[email protected]', 'SMTP SERVER')
->recipients('[email protected]', 'Ben Josiah');
$response = $smtp->sendEmail($email);
use SmtpExpress\Mail\SendMail;
$templateEmail = (new SendMail())
->subject('A Template message from the express')
->template('template-id', [
'name' => 'Josiah',
'company' => 'SMTP Express',
'url'=> 'https://yourapp.com/reset-password'
])
->sender('[email protected]', 'SMTP SERVER')
->recipients('[email protected]', 'Ben Josiah');
$response = $smtp->sendEmail($templateEmail);