Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
49 lines (36 sloc) 1.49 KB

MailerQ Transport Plugin for Swift Mailer

If you use Swift Mailer as your main mail engine in your project you can download MailerQ Transport Plugin to extend functionality of the Swift Mailer. Below you can find an example showing how to combine those two projects together.

example.php

<?php
// load required dependencies
require_once 'swiftmailer/lib/swift_required.php';
require_once 'MailerQPlugin/MailerQConnection.php';
require_once 'MailerQPlugin/MailerQTransport.php';

// an array with additional options
$options = array(
'ips'           =>  ['1.2.3.4','1.2.3.5'],
'maxattempts'   =>  5
);

// set up a connection to AMQP server
$connection = new MailerQConnection('localhost', 'outbox', 'guest', 'guest', '/');

// create the message using Swift_Message
$message = Swift_Message::newInstance();
$message->setSubject('This email was sent using Swift MailerQ Transport Plugin');
$message->setBody('Example message');
$message->setFrom('example@domain.com', 'Example');

// deliver the message to
$message->setTo('example@domain.com');

// create a new MailerQTransport instance
$transport = new MailerQTransport($connection, $options);

// create a new SwiftMailer instance
$mailer = Swift_Mailer::newInstance($transport);

// send the actual message using the MailerQTransporter
$mailer->send($message);

?>
You can’t perform that action at this time.