swarletta / swiftmailer
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Language:HTML
Requires
- swiftmailer/swiftmailer: ^6.0
- vlucas/phpdotenv: ^5.3
This package is not auto-updated.
Last update: 2024-11-05 08:32:35 UTC
README
Send emails from your site. Based on swiftmailer/swiftmailer.
##Install with Composer
composer require swarletta/swiftmailer
##Initialization First, you need to require a library that helps you work with .env files
Then create an instance of MailTransport. You will need that params:
For SMTP Server: smtp.gmail.com
– SMTP user: vashemail@gmail.com
– SMTP password: password from your Gmail account
– SMTP port: 465
– TLS/SSL: needed.
Here is an example of Swiftmailer call
<?php require 'vendor/autoload.php'; use App\MailTransport\MailTransport; use App\MailTransport\Message; use App\Render\Render; $dotenv = Dotenv\Dotenv::createUnsafeImmutable(__DIR__); $dotenv->load(); $mailTransport = new MailTransport( getenv('HOST'), (int) getenv('PORT'), getenv('USER_EMAIL'), getenv('USER_PASSWORD'), 'ssl' ); $templateName = 'auth'; $message = 'You have been successufuly authorization'; $templateMessage = (new Render())->build_email_template($templateName, $message); $mailTransport->send( new Message('Welcome', $templateMessage, getenv('EMAIL_TO')));