/ Published in: PHP

This is a little snippet to prevent sending emails to customers, in a local development environment, with Swiftmailer.
I didn't find any documentation about the RedirectPlugin, so I made this example.
Please refer to the official documentation to install Swiftmailer.
I didn't find any documentation about the RedirectPlugin, so I made this example.
Please refer to the official documentation to install Swiftmailer.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php $local = true; // Create the Mailer using any Transport $mailer = Swift_Mailer::newInstance( Swift_SmtpTransport::newInstance('smtp.example.org', 25) ); // Create the Message $message = Swift_Message::newInstance() ->setSubject('My subject') ->setTo('john-to@example.org') ->setCc('john-cc@example.org') ->setBcc('john-bcc@example.org') ->setBody('My content'); if( $local ) { // Register the RedirectPlugin, only in local development environment $mailer->registerPlugin(new Swift_Plugins_RedirectingPlugin('all_emails_belong_to_me@example.org')); // and then, no email will be sent to john-to@example.org or john-cc@example.org or john-bcc@example.org } // Send the Message $mailer->send($message);
URL: http://swiftmailer.org/docs/introduction.html
Comments
