Skip to content

Instantly share code, notes, and snippets.

@cythrawll
Last active August 29, 2017 21:54
Show Gist options
  • Save cythrawll/8824ad47061e6e77a0887958f624f92e to your computer and use it in GitHub Desktop.
Save cythrawll/8824ad47061e6e77a0887958f624f92e to your computer and use it in GitHub Desktop.
<?php
require_once '../vendor/autoload.php';
// Create the Transport
$transport = (new Swift_SmtpTransport('localhost', 1025));
// 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);
if($result) {
echo '<h1>MESSAGE SENT</h1>';
} else {
echo 'Email failed';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment