PHP code example of machour / swiftmailer-ethereal-transport
1. Go to this page and download the library: Download machour/swiftmailer-ethereal-transport 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/ */
machour / swiftmailer-ethereal-transport example snippets
use Machour\SwiftMailerEtherealTransport\EtherealTransport;
// Create the Transport
$transport = (new EtherealTransport())
// Get your credential at https://ethereal.email/create
->setUsername('your username')
->setPassword('your password')
// Display the URL in your logs, store it session, or whatever ..
->setCallback(function (string $url) use ($logger) {
$logger->debug("Email sent to Ethereal, see it at $url");
});
// Create the Mailer using your created Transport
$mailer = new Swift_Mailer($transport);
// Create a message
$message = (new Swift_Message('Wonderful Subject'))
->setFrom(['[email protected]' => 'John Doe'])
->setTo(['[email protected]', '[email protected]' => 'A name'])
->setBody('Here is the message itself');
// Send the message
$result = $mailer->send($message);